in reply to Extracting Text Lines

It seems to me that you could simplify the code like this.

open(FILE,"dumptape.log") || die ("Could not open file: $!"); my $success; for ( $success = 0; $success != 1 && <FILE>; ) { if ( /Dump phase number 3/ ) { print <FILE>; $success = 1; } } close ( FILE ); if ( !$success ) { print "Failed dump log\n"; #do other failed dump log stuff here }

Then again, maybe checking for success every time is overkill -- the last that you had in there works fine.

--t. alex
Life is short: get busy!

Replies are listed 'Best First'.
Re: Re: Extracting Text Lines
by Cine (Friar) on Jul 31, 2003 at 15:14 UTC
    print <FILE>;
    This wont do as you expect it to do. print puts is argument in list context, and a file handle in list context returns all the lines in the files. Thus you would print the remainder of the file after having found your line.

    T I M T O W T D I