in reply to how to skip certain lines and check for blank ones?
I might do something like this:
use strict; use warnings; open my $infile, '<', 'sss.txt' or die $!; while( my $line = <$infile> ) { $line =~ /^$/ and die "Blank line detected at $.\n"; $line =~ /^#/ and next; print "$.: $line"; } close $infile;
The first regexp matches (thus triggering the die) if the line is empty, or empty with a newline character at the end.
The second regexp matches (thus skipping to the next line) if a '#' is found as the first character of the line.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to skip certain lines and check for blank ones?
by davorg (Chancellor) on Oct 31, 2006 at 09:27 UTC |