Path: utzoo!attcan!uunet!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: sort differs in PL#36 from PL#28? Message-ID: <10063@jpl-devvax.JPL.NASA.GOV> Date: 22 Oct 90 17:17:55 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 49 In article ishii@hexard.co.jp (Koji Ishii) writes: : : sort in a packge is different. In PL#28, : : hxrdgw:~/unnews/test[21]% perl28 sorttest.pl : 1 5 4 9 : 1 4 5 9(28) : 1 5 4 9(36) : : But in PL#36 : : hxrdgw:~/unnews/test[22]% perl sorttest.pl : 1 5 4 9 : 1 5 4 9(28) : 1 4 5 9(36) : : Is this a feature or ??? sorttest.pl follows. : : #!/usr/bin/perl : &sorttest( 1, 5, 4, 9 ); : exit 0; : : package test; : : sub numerical28 { $main'a - $main'b; } : sub numerical36 { $a - $b; } : : sub main'sorttest { : local( @x ) = @_; : print "@x\n"; : local( @y ) = sort numerical28 @x; : print "@y(28)\n"; : local( @z ) = sort numerical36 @x; : print "@z(36)\n"; : } 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. Thus, $a and $b above are automatically package local variables, which is what you'd expect. I'm sufficiently into having Perl do what you expect that I thought it worthwhile to possibly break a few scripts to make things consistent. I kind of feel that this is my last chance to make such adjustments before the book comes out. Larry