The question of whether perl will return a string or number, which is thouroughly interesting, is a bit of a side issue.
What you seem to be attempting to do is change a lexically scoped variable from a different scope.
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
If you change the scope then you can probably put your local pc repair shop on speed-dial. I would advise not doing this with environment variables.
additional not sure about this really, though, I'd have thought if this was an issue here, there would have been some more responses of the kind. I may have misunderstood this a little.