in reply to While loop conditions in Perl
Note that /^\s$/ means a regex that starts at the beginning to the end of the input and comprises all 5 white space characters
[ \t\f\r\n]
Second Example:#!/usr/bin/perl -w use strict; my $firstNonBlankLine; while ($firstNonBlankLine = <DATA>, $firstNonBlankLine !~ /\S/){} print $firstNonBlankLine; =prints This first non-"blank" line =cut __DATA__ This first non-"blank" line this is second non-blank line
#!/usr/bin/perl -w use strict; while (<DATA>) { print if !/^\s$/; } =prints This first non-"blank" line this is second non-blank line =cut __DATA__ This first non-"blank" line this is second non-blank line
|
|---|