in reply to Re^3: Parsing a file to print multiple times
in thread Parsing a file to print multiple times
Thanks a lot Anonymous Monk.You rock!!!
This logic worked.Below is the final code :-
open (FILE, '<', 'sample.txt') or die "Could not open sample.txt: +$!"; open (FILE1, ">output1.txt") or die "Could not open sample.txt: $! +"; my @nums = <FILE>; my $start = "print from"; my $go = 0; my $sizeconf = scalar @nums; for my $num ( @nums ){ if ($num =~ /$start/) { $go = 1; } if($go){ print FILE1 "$num"; } my $end = "closing"; if ($num =~ /$end/ && $num !~ /$start/) { $go = 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Parsing a file to print multiple times
by ExperimentsWithPerl (Acolyte) on Sep 29, 2015 at 11:31 UTC |