in reply to Re: Find maximum number in text file and copying its full statement in new text file?
in thread Find maximum number in text file and copying its full statement in new text file?
Hi kcott,
First of all thank you for your reply and Good day to you...I have modified the code, so that it extracts the data from one file and copies those statements to new file...But, its not copying...
use strict; use warnings; my $re = qr{ \A \s+ ( \d+ ) }x; my $high = 0; my @lines; open (F1, "<designer.log") or die ; open (F2, ">>new_lines.txt") or die; while (<F1>) { /$re/ or next; my $num = $1; next if $num < $high; if ($num > $high) { $high = $num; @lines = (); } push @lines, $_; print F2 @lines; } print "Highest number: $high\n"; close (F1); close (F2);
Correct me if its wrong....
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Find maximum number in text file and copying its full statement in new text file?
by Anonymous Monk on May 07, 2015 at 06:16 UTC | |
by sumathigokul (Acolyte) on May 07, 2015 at 09:52 UTC | |
by parv (Parson) on May 07, 2015 at 14:16 UTC |
In Section
Seekers of Perl Wisdom