in reply to Re: File handles and loops
in thread File handles and loops
Thank you.sub my_close { my( $fh ) = @_; + close($fh) or die "$!\n"; } + sub my_open { + my( $file, $mode ) = @_; + open my $fh, $mode, $file or die "$!\n"; + return $fh; } sub errors { + my( $file, $mode ) = @_; my $fh = my_open($file, $mode); my @errors = (); while( <$fh> ) { chomp; + next if /^[a-z]/; push( @errors, qq(Line $. '$_' does not begin with lowercase l +etter.) ); } my_close($fh); # Safe to close file like this??? + + return @errors; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: File handles and loops
by tobyink (Canon) on Aug 01, 2012 at 06:29 UTC |