Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$ cat test1.pl #! /usr/bin/perl use warnings; use strict; use vars qw( $name ); $name = 'Matt'; require 'test2.pl'; $ cat test2.pl #! /usr/bin/perl use warnings; use strict; print "Hello, $name!\n"; 1; $ ./test1.pl Hello, Matt! $ perl -c test2.pl Global symbol "$name" requires explicit package name at test2.pl line +6. test2.pl had compilation errors.
I'm working with some legacy code that depends on this behavior, so I'd like to know if it's a Good Thing.
What's really happening here, in terms of package variables, namespaces, symbol tables, and importing? An 'RTFM' is fine, as long as you tell me which 'FM'. ;)
Thanks in advance!
-- Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 'use strict' and sharing globals between files
by ikegami (Patriarch) on Apr 07, 2009 at 20:46 UTC | |
|
Re: 'use strict' and sharing globals between files
by QM (Parson) on Apr 07, 2009 at 20:56 UTC | |
|
Re: 'use strict' and sharing globals between files
by morgon (Priest) on Apr 07, 2009 at 21:58 UTC | |
by Anonymous Monk on Apr 08, 2009 at 03:10 UTC |