Using grep on undefined array

Paul Makepeace paulm at
Wed Aug 14 18:10:26 BST 2013

On Wed, Aug 14, 2013 at 9:35 AM, Avishalom Shalit <avishalom at> wrote:
> wait, aren't $a and $b special  ?
> (they magically live for {$a<=>$b} etc. )

IIRC, they're local'ised within the sort block.

You can try it yourself,

$ perl -wle 'print "a=$a (pre init)"; $a = 5; @f = sort {print "a=$a
b=$b (in sort)"; $a <=> $b} (2,1); print "a=$a (later)"'
Name "main::f" used only once: possible typo at -e line 1.
Use of uninitialized value $a in concatenation (.) or string at -e line 1.
a= (pre init)
a=2 b=1 (in sort)
a=5 (later)


More information about the mailing list