- or download this
{
my $var = 'this string';
...
test1(); # var = this string
test2(); # var = (undef)
test3(); # var = this string
- or download this
# Module.pm
pacakge Module;
...
sub test1 { print("var = $var\n"); }
sub test2 { eval(' print("var = $var\n"); '); }
sub test3 { $var; eval(' print("var = $var\n"); '); }
- or download this
# script.pl
use Module;
Module::test1(); # var = this string
Module::test2(); # var = (undef)
Module::test3(); # var = this string