in reply to removing blank lines from files
Perhaps those "blank" lines contain spaces? Also, using chomp simply removes line endings (e.g. carriage return), it won't skip to the next line. You haven't really shown us your code, but presumably you need something like:
#!/usr/bin/perl -w use strict; while (<>) { # loop to next line if it contains whitespace only next if /^\s+$/; print; }
Update: Tested with files with blank lines consisting of just \n and blank lines with spaces; works in both cases; \s+ matches end-of-line characters, see perlretut (query from mirod & busunsl).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: removing blank lines from files
by busunsl (Vicar) on Jun 20, 2002 at 12:49 UTC | |
by mirod (Canon) on Jun 20, 2002 at 13:35 UTC |
In Section
Seekers of Perl Wisdom