Does anyone know why perl behaves like this? It seems to me
that since the scripts are running as seperate processes, there
should not be a problem.
The only information Ive found on the subject is this:
require - the file being required inserts the subroutine names
into a package ( a namespace ) of its own choosing, not
your package. Second, require happens at run-time, so
the decleration occurs to late to serve as a declaration
in the file invoking the require.
use - performs a require at compile time, then lets you import
declerations into your own namespace.
Would it behoove me to modify my library to be a perl module and
switch require to use? Would this solve my problem?
thanks
rodney
> -----Original Message-----
> From: Me [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 21, 2001 9:23 AM
> To: Rodney Holm; [EMAIL PROTECTED]
> Subject: Re: use of require causing name space problems?
>
>
> > sub WriteFile
> > {
> > my ($file,@lines) = @_;
> > my ($line);
> >
> > open(FILE,">$file");
>
> FILE is a problem.
>
> If you are using perl 5.6 or later, you can do:
>
> my $fh;
>
> and then use $fh where you were using FILE, eg
>
> open($fh, ">$file");
>
> If you aren't using 5.6, it gets more complicated
> and I'm out of, er, my depth. I'll post later if I see
> what to do, but I suggest you post again and ask.
>
> > foreach $line (@lines)
>
> $line is a problem.
>
> Fixing $line is easy. I'll let you guess. :>
> Ok, no I won't:
>
> foreach my $line (@lines)
>
> > {
> > print FILE $line; }
> > }
> > close(FILE);
> > return(0);
> > }
> > open(FILE,">$file");
>
>