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

Re: pattern matching in array

by gurpreetsingh13 (Scribe)
on Jun 20, 2013 at 11:24 UTC ( #1039953=note: print w/ replies, xml ) Need Help??


in reply to pattern matching in array

Simple one liner for the same.

perl -e 'my @ar = qw( adf "afaf faf ff" af "abf"); $_ =~ m/^\".+$/ && +print "Yes=",$_,"\n" foreach(@ar);'
Output:
Yes="afaf Yes="adf"


Comment on Re: pattern matching in array
Select or Download Code
Re^2: pattern matching in array
by hbm (Hermit) on Jun 20, 2013 at 11:36 UTC

    You don't need to escape the quote, nor gobble up the entire string. Simply: m/^"/

      hey

      now i am trying to work to find words starting with "" in array and I am doing this

       @foo_d = grep(/""/, @arr);  

      but it is not working , @foo_d always holds 1

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-08-23 03:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls