in reply to Re: Replace $a with $b if $a ne $b
in thread Replace $a with $b if $a ne $b

You should not be using $a and $b however, as they are "special" variables used by sort

Doesn't matter. sort localizes $a and $b.

$a = 1; print((sort { $b cmp $a } qw( a b c z y x )), $/); print($a, $/); # Prints "1"

Replies are listed 'Best First'.
Re^3: Replace $a with $b if $a ne $b
by tilly (Archbishop) on May 07, 2005 at 05:01 UTC
    Does too matter. Try this code on perl 5.8.x.
    my $a = 1; print((sort { $b cmp $a } qw( a b c z y x )), $/); print($a, $/); # Prints "1"