what you probably want is:

use vars qw|$foo @bar|;

but ONLY use that if you're REALLY sure what you're doing
globals are usually a bad idea.

hth
Jos

----- Original Message -----
From: "Tomasi, Chuck" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, November 08, 2001 4:45 PM
Subject: Defining Global Variables w/use strict;


> System: Sun Ultra 2, Solaris 7 (11/99)
> Perl: 5.6.0
>
> I have a series of related programs that need global definitions ($DOMAIN,
> $ADMIN, $DBNAME, etc).  My code looks something like this:
>
> ----------<g.pl>----------------
> #!/usr/local/bin/perl -w
>
> use strict;
> use DBI;
>
> require "defs.pl";
>
> print "Welcome to $DOMAIN, $ADMIN\n";
>
>
> ------------<defs.pl>------------
> #!/usr/local/bin/perl -w
>
> use strict;
>
> my $DOMAIN="plexus.com";
> my $ADMIN="Chuck";
>
> --------------------------------
>
> Of course, when I run g.pl I get the infamous,
>
> Global symbol "$DOMAIN" requires explicit package name at ./g.pl line 7.
> Global symbol "$ADMIN" requires explicit package name at ./g.pl line 7.
> Execution of ./g.pl aborted due to compilation errors.
>
> I've tried "my" and "local", but local just changes the error to complain
> about an explicit package being required.  I'm missing something basic.
>
> How can I define these variables to be known in g.pl, h.pl, and other
> programs that require defs.pl?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to