Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Reading particular line which repeats itself many times in text

by uday_sagar (Scribe)
on Jan 31, 2012 at 04:35 UTC ( #950875=note: print w/ replies, xml ) Need Help??


in reply to Re: Reading particular line which repeats itself many times in text
in thread Reading particular line which repeats itself many times in text

Monks, Thanks for your replies. I have solved the problem by putting together the concepts of non greedy quantifier(?) and storing the whole file (using File::Slurp) in a scalar variable. Here is the code.

use File::Slurp; local $/ = undef; open FILE, "my_text.txt" or die "Couldn't open file: $!"; binmode FILE; $string = <FILE>; close FILE; if ($string=~/BEGIN hi(.*?)END/s) { print ${1}."\n"; }


Comment on Re^2: Reading particular line which repeats itself many times in text
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-07-31 11:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (248 votes), past polls