## somewhat simplified version of the WriteFile sub
sub WriteFile
{
my ($file,@lines) = @_;
my ($line);
open(FILE,">$file");
foreach $line (@lines)
{
print FILE $line; }
}
close(FILE);
return(0);
}
> -----Original Message-----
> From: Me [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 21, 2001 8:45 AM
> To: Rodney Holm; [EMAIL PROTECTED]
> Subject: Re: use of require causing name space problems?
>
>
> You need to make sure that variables in the called perl
> code are unique to each instance of a call. (Sorry if that
> was already obvious to you.)
>
> I suggest you post the WriteFile code and we go from there.
>
> > I have a few functions that are common to many different
> > perl applications. All of these functions live in one
> > file.
> >
> > I have many perl programs that run from cron that make
> > use of these functions. So, in each of these programs
> > I use require to gain access to these functions.
> >
> > Example:
> >
> > <<<<< doit.pl >>>>>
> > #!/usr/bin/perl
> > require '/usr/local/myperllib.pl';
> > @array = ("one\n", "two\n", "three\n");
> > ## calling WriteFile from myperllib.pl
> > WriteFile('/path/filename', @array);
> > exit;
> > <<<<< doit.pl >>>>>
> >
> > <<<<< doit1.pl >>>>>
> > require '/usr/local/myperllib.pl';
> > @array = ("four\n", "five\n", "six\n");
> > ## calling WriteFile from myperllib.pl
> > WriteFile('/path/filename1', @array);
> > exit;
> >
> > imagine many of these doit.pl scripts ( doit1.pl, doit2.pl ... ), all
> using
> > require, all calling WriteFile, all running at the same time.
> >
> > What happens is sometimes, what should end up in one file, ends up in
> > another file. I would expect:
> > $ cat /path/filename
> > one
> > two
> > three
> >
> > what I sometimes get is the contents of /path/filename1 ending up in
> > /path/filename
> > $ cat /path/filename
> > four
> > five
> > six
> >
> > How would I code my library correctly to avoid this type of namespace
> > pollution?
> >
> > thanks
> > rodney
>
>