in reply to Re: Extracting specific Data
in thread Extracting specific Data

I tried the following
open(FILE, "<Google.txt") or die "Could not open file: $!"; while(<FILE>){ if(m/^Google/) { print $_; } }

My Google.txt has the following data

Google Google mahesh kumar sam

I am confused what if my file has multiple lines then?

Replies are listed 'Best First'.
Re^3: Extracting specific Data
by jayto (Acolyte) on Jun 26, 2012 at 13:24 UTC
    your code would work for one line, look at my code. I put the regex in a while loop and had /mg which means match globally, this makes it work for all lines in file. word1 is the word where you want to start recording the data and word2 is where you want to end the reading of the data. The (.+) is everything in between those two words (non inclusive), and $1 represents the data in (.+).