Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!sragwa!hxrdgw!ishii From: ishii@hexard.co.jp (Koji Ishii) Newsgroups: comp.lang.perl Subject: Re: sort differs in PL#36 from PL#28? Message-ID: Date: 24 Oct 90 02:17:08 GMT References: <10063@jpl-devvax.JPL.NASA.GOV> Sender: ishii@hexard.co.jp Distribution: comp Organization: Hexard Inc., Tokyo, Japan. Lines: 40 In-reply-to: lwall@jpl-devvax.JPL.NASA.GOV's message of 22 Oct 90 17:17:55 GMT In article <10063@jpl-devvax.JPL.NASA.GOV> lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: > In article > ishii@hexard.co.jp (Koji Ishii) writes: > : > : sort in a packge is different. In PL#28, : > This is part of what was meant when the patch said "package behavior is > now more consistent". Essentially, packages used to be strictly lexical > with certain exceptions such as eval and double-quoted strings. Messy. > Now the package of the currently executing statement is known at run-time, > so variables are automatically created in the current package without > having to make exceptions. : > Larry Thank you, it is a feature. So follows is the only way to sort in numerical order with both PL#28 and PL#36, isn't it? All other ways I tested failed but the following one. Are there better way to do this? #!/usr/bin/perl &sorttest( 1, 5, 4, 9 ); package test; sub numerical28 { $main'a - $main'b; } sub numerical36 { $a - $b; } sub main'sorttest { local( $numfunc ) = "numerical36"; $numfunc = "numerical28" if $] <= 3.028; print "numfunc = '$numfunc'\n"; local( @x ) = sort $numfunc @_; print "@x\n"; } -- ---------------------------------- Koji Ishii Hexard Inc., Tokyo, Japan. JUNET: ishii@hexard.co.jp