in reply to Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
Noting a point which hasn't come up yet:
which I assumed, in accordance with perldoc, would roughly translate to:
my %res; foreach my $word (@rw) { $res{$word} ||= do { my $re; $re .= $translations{$_} for split //,$word; $re; } }
No, it doesn't. You are using || here; that shortcircuits, ie if $res{$word} already exists (and is true), then the do {} won't even execute. There's no way to duplicate this with map.
Btw, this:
my $re; $re .= $translations{$_} for split //,$word; $re;
is more succintly expressed as
join '', @translations{ split //, $word };
Makeshifts last the longest.
|
|---|