Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!sragwa!hxrdgw!ishii From: ishii@hexard.co.jp (Koji Ishii) Newsgroups: comp.lang.perl Subject: Yet another BUG in sort and package in PL#37 Message-ID: Date: 28 Oct 90 07:13:46 GMT Sender: ishii@hexard.co.jp Distribution: comp Organization: Hexard Inc., Tokyo, Japan. Lines: 56 Larry said $a and $b in sort function is bound to current package at PL#36. But it seems to have a bug, please look at package yy in following sample. Here, $a and $b are not bound to package yy but package xx. I wonder why they are bound to such names as $a and $b, not to $_[0] and $_[1]. This is the only case where perl requires special names to programmers. Could you explain if I'm missing something? hxrdgw:~/unnews/test[21]% perl28 sorttest.pl 28:1 4 5 9: 36:9 5 4 1: 28:1 4 5 9: 36:9 5 4 1: XX:9 5 4 1: hxrdgw:~/unnews/test[22]% perl sorttest.pl 28:9 5 4 1: 36:1 4 5 9: 28:9 5 4 1: 36:9 5 4 1: XX:1 4 5 9: #!/usr/bin/perl &sorttest( 9, 5, 4, 1 ); &sorttest2( 9, 5, 4, 1 ); package xx; sub numerical28 { $main'a - $main'b; } sub numerical36 { $a - $b; } sub main'sorttest { local( @x ) = sort xx'numerical28 @_; print "28:@x:\n"; @x = sort xx'numerical36 @_; print "36:@x:\n"; } package yy; sub numerical28 { $main'a - $main'b; } sub numerical36 { $a - $b; } sub numerical36_bug { $xx'a - $xx'b; } sub main'sorttest2 { local( @x ) = sort yy'numerical28 @_; print "28:@x:\n"; @x = sort yy'numerical36 @_; print "36:@x:\n"; @x = sort yy'numerical36_bug @_; print "XX:@x:\n"; } -- ---------------------------------- Koji Ishii Hexard Inc., Tokyo, Japan. JUNET: ishii@hexard.co.jp