in reply to Re: package globals and sort()
in thread package globals and sort()
and of course I get an error. sigh. I wonder if AUTOLOAD could do it. I never used that before...package MyOrder; use strict; # export junk goes here... my %order = ( # order hash goes here... ); sub SortMyWay { if ( exists $order{$a} and exists $order{$b} ) { return $order{$a} <=> $order{$b} } elsif ( exists $order{$a} ) { return 1 } elsif ( exists $order{$b} ) { return -1 } else { return $a cmp $b } } package main; use strict; # use the module with the sort stuff in it, # which also exports sub SortMyWay my @foo = ( # stuff to sort goes here... ); my @bar = sort SortMyWay @foo;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: package globals and sort()
by tachyon (Chancellor) on Apr 19, 2002 at 01:10 UTC | |
by Anonymous Monk on Apr 19, 2002 at 01:48 UTC | |
by tachyon (Chancellor) on Apr 19, 2002 at 02:09 UTC |