Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Extract pattern match from file

by johngg (Canon)
on Sep 17, 2016 at 21:47 UTC ( [id://1172024]=note: print w/replies, xml ) Need Help??


in reply to Extract pattern match from file

It is also worth pointing out that double quotes are not regular expression meta-characters and do not need to be escaped.

johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<EOD or die $!; nothing "hello" foo "bar" quz "hello2" "world" foo2 "bar2" quz2 "baz" blah blah2 "" blah3 many lines of unquoted stuff "example 1 for instance" EOD my $data = do { local $/; <$inFH>; }; close $inFH or die $!; say qq{-->$1<--} while $data =~ m{"([^"]*)"}g;' -->hello<-- -->bar<-- -->hello2<-- -->world<-- -->bar2<-- -->baz<-- --><-- -->example 1 for instance<-- johngg@shiraz:~/perl/Monks >

I hope this is helpful.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-23 17:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found