in reply to removing empty lines
It doesn't quite look like your code matches your request; you don't seem to be removing empty lines, but skipping them.
If what you want to do is to ignore blank lines while reading a file, I would do something like this (note that this code is not tested:
open(my $infile, '<', $inputfile) or die "Could not open $inputfile be +cause $!\n"; while(<$infile>){ next if /^\s*$/; chomp; # you don't want the newline, do you? #processing follows here... } close($infile); }
I'm defining "blank line" to be any line comprising only whitespace characters.
Note that tr or y does not handle character classes (to quote: "Note that tr does not do regular expression character classes such as \d or [:lower:]"; see perlop)
(note that most Monks are paid to review people's code; some pleasant words like "please" would be nice when asking for free services).
emc
Insisting on perfect safety is for people who don't have the balls to live in the real world.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: removing empty lines
by mikejones (Scribe) on May 18, 2007 at 17:38 UTC | |
by MonkE (Hermit) on May 18, 2007 at 19:22 UTC | |
by swampyankee (Parson) on May 19, 2007 at 01:05 UTC |