Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: (Mis)Understanding <c>grep...eq $_<c>

by wfsp (Abbot)
on Feb 24, 2009 at 06:47 UTC ( #745914=note: print w/replies, xml ) Need Help??


in reply to (Mis)Understanding grep...eq $_

grep EXPR, LIST
Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each element) and returns the list value consisting of those elements for which the expression evaluated to true.
So, in this case, grep takes a list and returns a list.
my @list = (1, 2, 3, 4, 5); my @result = grep $_ > 2, @list; print "@result";
3 4 5
You could probably get away with something like
if (exists $item_lookup{$name}){ print qq{$name has $item_lookup{$name}}; else{ print qq{$name is missing $item_lookup{$name}; }
in your for loop.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2022-01-19 19:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?