Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: string diff and compare

by jwkrahn (Monsignor)
on May 04, 2012 at 21:27 UTC ( #968989=note: print w/ replies, xml ) Need Help??


in reply to Re^2: string diff and compare
in thread string diff and compare

my ( $rold, $rnew ) = map scalar reverse, $old, $new;

Is just a different way of saying:

my $rold = reverse $old; my $rnew = reverse $new;

You need to use scalar because reverse is in list context in the map expression.


Comment on Re^3: string diff and compare
Select or Download Code
Replies are listed 'Best First'.
Re^4: string diff and compare
by tobyink (Abbot) on May 05, 2012 at 07:17 UTC

    There are other ways of enforcing scalar context which are a lot more fun. :-)

    use 5.010; use strict; use warnings all => 'FATAL'; my ( $old, $new ) = qw( old new ); my ( $rold, $rnew ) = map~~reverse, $old, $new; say for "$old => $rold", "$new => $rnew";
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2015-07-31 09:07 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 (276 votes), past polls