Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: map and grep or clear code?

by choroba (Cardinal)
on Jan 31, 2012 at 10:16 UTC ( [id://950927]=note: print w/replies, xml ) Need Help??


in reply to map and grep or clear code?

I would use grep, but remove the and $filter_clean from inside its condition. If you really want to check it, do it just once before running grep, repeating it when the variable does not change is useless. Also, map returns a list, but you want to concatenate a string, so use join. If you add numbers to your %filter_map (e.g. by
$filter_map{$_} = $_ for 0 .. 9;
), you can simplify it to
$filter .= join q{}, map $filter_map{ uc $_ }, split //, $filter_clean +;
which seems pretty clear to me.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-24 01:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found