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:
forforeach loop

 



parham_m_s
journeyman

May 27, 2001, 8:17 AM

Post #1 of 2 (407 views)
forforeach loop Can't Post

i have two foreach loops imbedded into each other...


Code
foreach $username (@usernames) { 
if ($username eq "") { next; }
foreach $stop (@stop) {
if ($username eq "$stop") {
push(@no, $username);
next;
}
}
push(@yes, $username);
}

what i meant to do was that if the inside foreach loop's $username = $stop, then go to the next array in the outside loop. Just looking for a simple solution, any help is appreciated, thank you.



randor
User

May 27, 2001, 9:23 AM

Post #2 of 2 (404 views)
Re: forforeach loop [In reply to] Can't Post

parham_m_s,

i believe(if i read that right), that what you need is to change :
if ($username eq "") { next; }
to
if ($username eq "") { last; }

that will send you out of the second loop, and to the next issue in the first loop.


I Hope this helps...

perl programmers don't die.. they just start writing a new script.

 
 


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

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