Kathy,

A blank line can have several definitions including (after the chomp) a zero
length or space filled. I'm certain you will receive several different
approaches to this, here are my humble suggestions:

next unless (length($fileline));
next if ($fileline =~ /^\s+$/);

Note that you could restructure your while loop to:

while (<IN>)
{
    chomp;
    next unless (length);
    next if (/^\s+$/);
    print "One line: $_\n";
}

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
----- Original Message -----
From: "Katherine Richmond" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 11, 2002 10:52
Subject: How to skip over a blank line


> Hi everyone,
>
> I am parsing a file and need to recognize when I have come to a blank
line. Can
> you tell me how to do this? Here is my code so far:
>
> while ( defined($fileLine = <IN>) ) {
>
> chomp ($fileLine);
>
> #if this line is blank, go to next line
>
> #if ($fileLine
>
> print "\nOne line: " . $fileLine;
> }
>
>
> Thank you,
> Kathy
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>

_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to