in reply to Re: sort routines crossing package lines
in thread sort routines crossing package lines
Use prototypes on your sort subs so instead you would have sub caseless ($$) { lc($_[0]) cmp lc($_[1]) }
Yes, but I don't want to. perldoc -f sort claims that this introduces a performance hit and the application is already slow enough. I'm sorting lists with thousands of elements.
Or use the full name of $a and $b like this sub caseless { lc($main::a) cmp lc($main::b) }That is only true if all uses of the sort routine are in package main. In this application this is not the case. This routine has to work when called from a number of different packages.
BTW, I'm not necessarily looking for an alternate implementation. What I'm looking for is understanding the reason why exporting $a and $b does not make this work, but exporting their typeglobs does.
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: sort routines crossing package lines
by ides (Deacon) on Nov 24, 2004 at 21:50 UTC | |
|
Re^3: sort routines crossing package lines
by TomDLux (Vicar) on Nov 25, 2004 at 16:51 UTC | |
by DrWhy (Chaplain) on Nov 26, 2004 at 14:52 UTC |