Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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)


Comment on Re: Grep with AoA
Select or Download Code

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 lurking in the Monastery: (12)
As of 2014-09-23 13:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (221 votes), past polls