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";
You could probably get away with something like3 4 5
in your for loop.if (exists $item_lookup{$name}){ print qq{$name has $item_lookup{$name}}; else{ print qq{$name is missing $item_lookup{$name}; }
|
---|
In Section
Seekers of Perl Wisdom