Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Sort and related stuff

by leons (Pilgrim)
on Feb 23, 2001 at 15:58 UTC ( #60469=note: print w/ replies, xml ) Need Help??


in reply to Re: Sort and related stuff
in thread Sort and related stuff

Hi,

Thanks a lot for your help ! I just tried the solution Tyke
came up with. And it seems like a pretty good one (use vars qw/$a $b/;)
I tried it and it works perfectly and I haven't been able to
create a situation in which it doesn't work. So I think I'll go for
this one.

Thank you all for thinking along with me ! ;-)

And now for some lunch ! Bye, Leon


Comment on Re: Re: Sort and related stuff
Re: Re: Re: Sort and related stuff
by Corion (Pope) on Feb 23, 2001 at 16:39 UTC

    This solution has the same problems as my my-predeclare solution has. If somebody is stupid enough to assign something to $a and $b, then this method won't work for the single-call case. But on the other side, the single-call case will never work, if somebody actually uses variables called $a and $b in any way other than within a sort-callback.

      No. Your my-declaration had the problem that you changed $a and $b to lexical variables, so when the sort function was setting the globals $a and $b, the function looked at the wrong variables.

      Let us not mention the fact that your example assumed that the data never would include false values...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://60469]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2015-07-07 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls