in reply to Re: Re: Re: No other way?
in thread No other way?

Another reason to avoid /^$/ is that it non-intuitively matches a single newline:
#!/usr/bin/perl -wT use strict; # only one one of these is an "empty" string right? my @arr = ("", "\n", "dog", "cat"); my @haslength = grep {length} @arr; my @notempty = grep {!/^$/} @arr; print scalar @haslength, " members have length\n"; print scalar @notempty, " members are not \"empty\"\n"; __END__ =head1 OUTPUT 3 members have length 2 members are not "empty"
So, /^$/ actually classifies a single newline as an "empty" string.... Sometimes thats what you want, but it isn't usually what people expect.

-Blake