CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [sfo_sc] Read a file from a specific line and extract something to another file: Edit Log



KevinR
Veteran


Jan 20, 2005, 12:10 AM


Views: 2823
Re: [sfo_sc] Read a file from a specific line and extract something to another file

I think maybe you want to use "if" instead of "while" here:


Code
while ($file[$i] =~ m/^\t/ || $file[$i] =~ m/^Caused/  
|| length($file[$i]) == 0 || $file[$i] =~ m/^\s/) {
push(@temp, $file[$i] . "\n");
$i++;
}


"while" is generally used for looping through lists or files while a condition is true. "if" is used to make a decision based on the evaluation of an expression.

what you have is something like this:


Code
$num = 1; 
while ($num == 1) {
print "AHHHH!!";
}


since $num will always equal 1, the condition will always be true, and the loop will never exit. Now go get some sleep! Wink
-------------------------------------------------


(This post was edited by KevinR on Jan 20, 2005, 12:13 AM)


Edit Log:
Post edited by KevinR (Veteran) on Jan 20, 2005, 12:13 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives