Alok Bhatt wrote:

> > Hi all:
>  Hi Tomas,
> > I cannot include a file so it can return all the
> > variables I assigned.
> > #FILE1.pl
> > $var1= "tom";
> > #FILE2.pl
> > do FILE1.pl
> > #open $prog,'FILE1.pl' or die $!,
> > #use 'FILE1.pl'
> > #import 'FILE1.pl'
>
> In FIle2:
> do "FILE1.pl" (use double quotes)
>
> If you want to use "use <xxxx>", rename xxxx to
> file1.pm and use "use file1", instead of "use
> file1.pm".
>
> Hope that helps.
> :-)
> Alok

There is a larger conceptual issue here.  I think the OP is starting out on the
wrong track with this approach.  Declaring variables in remote files is just not
a good idea.  Perl has evolved, and evolved much better ways to handle
containment.

I would ask what purpose is he trying to achieve by doing this.Generally, when
people declare variables in included files, they are trying to create global
variables.  I think it is better to steer him towards safer ways of sharing data
between parts of a program.

Besides, double quotes are not neccesary:

rags.pl:

#!perl -w

$badly_named_variable = 5;

Greetings! E:\d_drive\perlStuff>perl
do 'rags.pl';
print "$badly_named_variable\n";

^Z
5

Though you could not get away with junk like this using strict.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to