Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get around blank line

Status
Not open for further replies.

alan12

Programmer
Oct 8, 2002
3
US
When I read plain text file such as:
=======
line1 aaaaaa;
line2 bbbbbb;

line4 dddddd;
=======

who can I write code to skip line3(which is blank) and read line4 instead?
 
One way to skip a blank line:
Code:
while(<F>) {
    next unless (/\S/); # skip unless line has a non-white space character 
    # do something
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top