SPUG: use strict and do files.

Stuart Poulin stuart_poulin at yahoo.com
Wed Jul 28 19:18:16 CDT 1999

--- Tim Maher/CONSULTIX <tim at consultix-inc.com> wrote:
> ... 
> By the way, we've got 243 members on our list now - mostly
> lurkers!

I was a proud member of the SPLG (Seattle Perl Lurkers Group) but now I have a

I was looking for a cheap rc type file behavior.  I thought I could just use a
"do" file with variables in it - but I wanted "use strict" to be enforced. The
perlfunc man page says:
   do 'stat.pl';
     is just like 
   scalar eval `cat stat.pl`;

This doesn't appear to be true.  This is on win98 so s/cat/type/ but "type" is
expensive as far as run time.  Is there a way to force a "use strict" on do



use strict;
use vars qw($one);

package doit;
use strict;
use vars qw($one $two);

package main;
$one = "main_one";

package doit;
do "doit.pl";

package main;
print "Would like to see and error on doit::whoops but don't\n";
print "$one $doit::one $doit::two $doit::whoops\n\n";

package doit;
print "Now I'll see and error\n";
scalar eval `type doit.pl`;

package main;
print "$one $doit::one $doit::two $doit::whoops\n";

# doit.pl
#use strict;
$one = "doit_one";
$::one = "main_one";
$two = "doit_two";
$whoops = "toss_an_error";

This outputs:
Would like to see and error on doit::whoops but don't
main_one doit_one doit_two toss_an_error

Now I'll see and error
Variable "$whoops" is not imported at (eval 1) line 6.
Global symbol "$whoops" requires explicit package name at (eval 1) line 6.
main_one doit_one doit_two toss_an_error

Do You Yahoo!?
Free instant messaging and more at http://messenger.yahoo.com

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address

More information about the spug-list mailing list