in reply to magic $a, $b and sort

I tried to reproduce but without luck, it complains independently of strict:
#!/usr/bin/perl #use strict; #use warnings; #use diagnostics; my $a; my @array = sort { $a <=> $b } 19, 28, 1 .. 3; print "@array\n"; __END__ Can't use "my $a" in sort comparison at oha2.pl line 7
Which version of perl are you using? I tested it with 5.8.4 and 5.8.8, both on Linux.

Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: magic $a, $b and sort
by oha (Friar) on Sep 05, 2007 at 15:27 UTC
    5.8.4 linux, but you are right. probably i used $::a while my $a, sorry :(

    Oha

    PS: i also found that the $a and $b are considered magic in perlvar too