use strict; use warnings; #use vars ('$M','$N'); # local $SIG{__WARN__} = sub { $N=24 }; my $t_num = sub { $N=24 }; printf "\nThe value of N is now %s %d %o\n",$N,$N,$N; $M = sprintf "%x", 41; printf "\nThe value of M is now %s %d %o\n",$M,$M,$M; my $t_var = sub { $M = 42; # printf "\nThe value of M is now %s %d %o\n",$M,$M,$M; sub { $M }; }; printf "\nThe value of t_var is now %s %d %o\n",$t_var->(),$t_var->(),$t_var->(); printf "\nThe value of M is now %s %d %o\n",$M,$M,$M; =head1 output Global symbol "$N" requires explicit package name at v42_13.pl line 10. Global symbol "$N" requires explicit package name at v42_13.pl line 11. ... Global symbol "$M" requires explicit package name at v42_13.pl line 23. Global symbol "$M" requires explicit package name at v42_13.pl line 23. Execution of v42_13.pl aborted due to compilation errors. =cut =head uncommented 'use vars ('$M','$N');' output Use of uninitialized value $N in printf at v42_13.pl line 11. Use of uninitialized value $N in printf at v42_13.pl line 11. Use of uninitialized value $N in printf at v42_13.pl line 11. The value of N is now 0 0 The value of M is now 29 29 35 The value of t_var is now CODE(0xxxxxxxxxx) dddddddd ddddddddddd The value of M is now 42 42 52 =cut