The label worked kandura, however it did not break the STDIN loop until after STDIN was finished reading the incoming data...
Basically my script reads the incoming data from an uploading file, finds out what the filename is and if a checkbox named overwrite was checked. If the filename exists and the overwrite box was not checked, I need to exit the STDIN loop before the upload data is read to 100%... I don't want to keep people waiting around for an hour for their upload to finish, only to find out it already exists. ;)
Code as it is now::
OUTER;
while(<STDIN>){
if(this exists){dothis}
if(this exists){dothis}
if(this is true && this is true)
{
&call_file_exists_sub;
last OUTER; ### break to OUTER label, doesn't break STDIN data read though...
}
}
I have add points on this question...
Main Topics
Browse All Topics





by: kanduraPosted on 2003-11-06 at 02:02:25ID: 9693082
Use 'last' keyword to do that. It will take you outside the enclosing loop.
Note that if you have another loop inside the outer loop, then last takes you outside the inner loop.
If you want to jump outside the outer loop, use a label just before the outer loop, and call 'last LABEL;' to jump out of the outside loop.
See the perlfunc manpage for a better description, but here's an example:
OUTER: # a label for the outer loop
while($something) {
# ... do stuff
while($inner) {
# ... do stuff
last if $cond1; # this will take you to COND1
last OUTER if $cond2; # this will take you to COND2
}
# COND1
# do more stuff in outer loop
}
# COND2
HTH,
Kandura