PerlingTheUK has asked for the wisdom of the Perl Monks concerning the following question:
Please excuse the very general header but I am not sure as to where the actual problem is and therefore just list my two main suspects.
I have a file with lines that need to be deleted. Each of these lines matches the pattern /^AB.*C$/. The whole code is:
open my $IN, "<", $infile || croak( "Could not open file $infile: $EXTENDED_OS_ERROR" ); open my $OUT, ">", $outfile || croak( "Could not open file $outfile: $EXTENDED_OS_ERROR" ); while ( <$IN> ){ my $line = $_; chomp $line; if ( $line !~ /^AB.*C$/ ){ print $OUT $line . "\n"; } } close $IN; close $OUT;
While this is removing the lines I am looking for, it also seems to not fully write some of the not excluded lines and extends them by several thousand characters shown as '^@' in XEmacs. I am not sure what might cause this or where to start looking.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing into files and RegExp
by Corion (Patriarch) on Mar 10, 2006 at 10:25 UTC | |
by PerlingTheUK (Hermit) on Mar 10, 2006 at 10:32 UTC | |
by Corion (Patriarch) on Mar 10, 2006 at 10:42 UTC | |
by PerlingTheUK (Hermit) on Mar 10, 2006 at 10:52 UTC | |
|
Re: Writing into files and RegExp
by davidrw (Prior) on Mar 10, 2006 at 14:12 UTC | |
|
Re: Writing into files and RegExp
by wfsp (Abbot) on Mar 10, 2006 at 10:43 UTC | |
by PerlingTheUK (Hermit) on Mar 10, 2006 at 10:50 UTC |