Dave Thacker wrote: > Perl 5.6 on linux > > Given this test file. > ------start--------- > this > > is > > my file > --------end---------- > I want to skip the blank lines and just print the lines with text, like this > this > is > myfile > > This is my test case code. > #!/usr/bin/perl -w > use strict; > > my $opt_testfile="test-text.txt"; > open (TS, $opt_testfile) or die "can't open file"; > while (<TS>) { > chomp; > next if ($_ =~ /^\s+/); > print "$_\n"; > } > > I'm not skipping the lines. My regex must be wrong. Can someone show me my > error please?
Either: next if /^\s*$/; Or: next unless /\S/; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>