Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

james2vegas's scratchpad

by james2vegas (Chaplain)
on Aug 08, 2009 at 01:11 UTC ( [id://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";
HANDLERS of XML-Parser/Parser.pm
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-19 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found