in reply to Get file part from the section where the matched pattern is found.
output#! /usr/bin/perl -w use strict; open(FILE,"< file1.txt"); my @lines=<FILE>; close(FILE); my $found=0; foreach my $line(@lines) { if($found) { print "$line"; } if($line=~/start/) { $found=1; print "$&$'"; } }
contents of file werestartdexdbnjcrk this when be shown this will be shown this will also be shown
anjwdwus svwbsdncelf,c;rf wscgwhjdke ff ed iekd ewd asvdjcn startdexdbnjcrk this when be shown this will be shown this will also be shown
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get file part from the section where the matched pattern is found.
by rockstar99 (Novice) on Nov 29, 2011 at 10:57 UTC | |
by ansh batra (Friar) on Nov 29, 2011 at 11:03 UTC |