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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Foreach regex

Status
Not open for further replies.

jriggs420

Programmer
Sep 30, 2005
116
US
Hello again,

I have the following loop:
Code:
     20 my $line;
     21 foreach $line (@_){  do sth ;  }
Simple enough, but I can't figure out how to only set $line equal to strings that contain no text (blank whatever). I have tried the following conditions in various places within the loop with no success. Any ideas?

!/^\s*$/ and !~/^\s*$/
@_ = grep { $_ !/^\s*$/} @_;
TIA

Joe

A clever person solves a problem.
A wise person avoids it.

-- Einstein
 
nvm stupid question. sry bout that

A clever person solves a problem.
A wise person avoids it.

-- Einstein
 
well, for edification, you're matching lines that don't contain only spaces because you are using the negation operator "!", just remove the ! and it should work.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top