Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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);'
Yes="afaf Yes="adf"

Comment on Re: pattern matching in array
Select or Download Code
Replies are listed 'Best First'.
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/^"/


      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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2015-11-29 08:21 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (749 votes), past polls