Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: regex on previous lines

by si_lence (Deacon)
on Jan 31, 2013 at 17:16 UTC ( #1016363=note: print w/ replies, xml ) Need Help??


in reply to regex on previous lines

another possibilty is to read the whole file in one string and match it there

use strict; use warnings; #slurp mode, read whole file in one variable $/ = undef; my $text = <DATA>; if ($text =~ /xxxxx.*?\n.*?yyyyy.*?\n.*?zzzzz/) { print "match \n"; } else { print "no match \n"; } __DATA__ xxxxx bla yyyyy bla bla zzzzz
if you want to match only if the three lines are excatly xxxxx, yyyyy and zzzzz respectivly, remove the .*? from the regex


Comment on Re: regex on previous lines
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2015-07-31 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (274 votes), past polls