dilip wrote:
hi all,
Hello,
suppose i have a file having the following data..
SN = TOM
FDN = SALLY
OPERATIONAL STATE = ENABLED
Now suppose i grep the string "ENABLED", i get the third line.But from
this very line i need to go 2 lines above and get the SN value
also.Please suggest .
Something like this should work:
my @buffer;
while ( <> ) {
push @buffer, $_;
shift @buffer if @buffer == 4;
if ( /ENABLED$/ ) {
splice @buffer, 1, 1;
last;
}
}
print @buffer;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/