Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Re: Date comparison

by dws (Chancellor)
on Jul 05, 2002 at 23:07 UTC ( [id://179760]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Date comparison
in thread Date comparison

Since str2time() is a relatively expensive routine, this a perfect time for pulling out the "Orcish Maneuver".

In the example above, change   my @sorted = sort {str2time($a) <=> str2time($b)} @dates; to

my %cache; my @sorted = sort {($cache{$a} ||= str2time($a)) <=> ($cache{$b} ||= str2time($b)) } @dates;

Replies are listed 'Best First'.
Re: Re: Re: Re: Date comparison
by George_Sherston (Vicar) on Jul 08, 2002 at 09:48 UTC
      But why "orcish"?

      The Orcish Maneuver gets its name from the use of the "or" assignment operator (||=) to "cache" values within a Schwartzian transform. "or" + "cache" --> "orcish".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-25 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found