in reply to Re (tilly) 3: $a and strict
in thread $a and strict

Of course, one can skirt the issue in version 5.6+ using prototypes because then the arguments arrive in @_ as with ordinary subroutines (though it will be slower than the package variable method):

#!/usr/bin/perl -w use strict; package Foo; sub numeric1 ($$) { my($a, $b) = @_; # could use any variable names $a <=> $b } # or just sub numeric2 ($$) {$_[0] <=> $_[1]} package main; my($a, $b) = (13, 42); my @array = (3, 2, 5, 3, 4, 1); my @sorted1 = sort Foo::numeric1 @array; print "@sorted1\n"; my @sorted2 = sort Foo::numeric2 @array; print "@sorted2\n";

Replies are listed 'Best First'.
Re: Re: Re (tilly) 3: $a and strict
by Anonymous Monk on Jul 19, 2001 at 16:09 UTC
    tiny-e says "Whoa, look at that node, it's huge!" ;)
    sub sorte {shift<=>shift}
      This is being downvoted and was considered for reaping as troll droppings.
      Maybe all he's trying to say (crudely) is: wouldn't
      sub sorte($$) {shift <=> shift}
      do the same thing with a lot less code?
      I haven't thought about it too much, but would it?

        p