> -----Original Message-----
> From: Dave Thacker [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 07, 2005 07:05
> To: beginners@perl.org
> Subject: Skipping blank lines while reading a flat file.
> 
> 
> 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?
> 
> TIA
> DT

Try dropping the parens -

next if $_ =~ /^\s+/;

HTH -
Ron


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to