Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

james2vegas's scratchpad

by james2vegas (Chaplain)
on Aug 08, 2009 at 01:11 UTC ( #786972=scratchpad: print w/ replies, xml ) Need Help??

my %sorts = ( 'case sensitive forward' => sub { $_[0] cmp $_[1] }, 'case insensitive forward' => sub { uc $_[0] cmp uc $_[1 +] }, 'case sensitive backward' => sub { $_[1] cmp $_[0] }, 'case insensitive backward' => sub { uc $_[1] cmp uc $_[0 +] }, 'case sensitive forward reverse' => sub { reverse($_[0]) cmp r +everse($_[1]) }, 'case insensitive forward reverse' => sub { uc reverse($_[0]) cm +p uc reverse($_[1]) }, 'case sensitive backward reverse' => sub { reverse($_[1]) cmp r +everse($_[0]) }, 'case insensitive backward reverse' => sub { uc reverse($_[1]) cm +p uc reverse($_[0]) }, ); # 5.10+ only #sub do_sorts { # state %cache; # my $res = $cache{$_[0], $_[1]}; # return if defined($res); # foreach my $sort (@{$_[2]}) { # $res ||= $sorts{$sort}->(@_) # } # $cache{$_[0], $_[1]} = $res #} { my %cache; sub do_sorts { my ($first, $second, @sort_list) = @_; my $res = $cache{$first, $second}; return $res if defined($res); foreach my $sort (@sort_list) { $res ||= $sorts{$sort}->($first, $second); last if $res } $cache{$first, $second} = $res } } my @list = qw(foo Bar baz Fuzz); print join(', ', sort { do_sorts($a,$b,('case sensitive forward revers +e')) } @list)."\n";
XML-Parser/Parser.pm#HANDLERS
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-09-18 10:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (111 votes), past polls