http://qs321.pair.com?node_id=1125946


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....