On Wed, Jun 6, 2012 at 10:27 AM, Matt <matt.mailingli...@gmail.com> wrote:
> Looking at some old code I wrote.
>
> my @listing;
> open(IN, list.txt) or die $!;
> while (<IN>) {
>    chomp;
>    next if /^\s*$/;
>    next if /^#/;
>    push(@listing, $_);
> }
> close IN;
>
> I want to trim any new lines off end of data.  chomp does that.  I
> want to skip any lines that begin with # and next if /^#/ does that.
> I also want to skip any lines that begin with whitespace.  How would I
> do that?  I thought /^\s*$/ did but it is not.
>

Shawn has already provided an answer, but I wanted to point out what
your regular expression (/^\s*$/) is doing. That expression is
matching any string that is empty or only contains whitespace.
HTH, Ken

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to