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

Re: Grep with AoA

by moritz (Cardinal)
on Aug 27, 2012 at 09:43 UTC ( #989954=note: print w/replies, xml ) Need Help??


in reply to Grep with AoA [Solved]

use strict; use warnings; use diagnostics; my @list = (["qwe", 1], ["qwer", 2], ["tyui", 3], ["asdf", 4], ["ghjk" +, 5], ["zxcv", 6] ); for my $item ("qwe", "qwer", "tyu", "yui", "tyui") { print grep($_->[0] ~~ /^$item$/, @list) . " " . $item . "\n"; }

Though of course if you check for equality, you can also write grep($_->[0] eq $item, @list)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2016-10-01 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (8 votes). Check out past polls.