On Mon May 14 17:23:59 2012, jimav wrote: > > References to undefined variables $a or $b do not cause an > error or warning inside eval "...". > > #!/usr/bin/perl > use strict; use warnings; > > for my $varname ('a' .. 'z') { > my $value = eval " \$${varname}->[42] "; > if ($@) { > print "EVAL ERROR: $@\n"; > exit 1; > } > print "No error for varname '${varname}', result is ", > (defined $value ? $value : 'undef'), "\n"; > } From perlvar: =item $a =item $b X<$a> X<$b> Special package variables when using C<sort()>, see L<perlfunc/sort>. Because of this specialness C<$a> and C<$b> don't need to be declared (using C<use vars>, or C<our()>) even when using the C<strict 'vars'> pragma. Don't lexicalize them with C<my $a> or C<my $b> if you want to be able to use them in the C<sort()> comparison block or function. -- Father Chrysostomos --- via perlbug: queue: perl5 status: new https://rt.perl.org:443/rt3/Ticket/Display.html?id=112934Thread Previous