in reply to Can't "last" outside a loop block

Your Perlmonks-fu needs work. Your post currently says this:

This is, essentially, useless. You should have enclosed your code inside code tags, and this *should* have been obvious when you *previewed* your post.

It should have looked something like this:

if ( -e "testfile" ) { $check = 0; print "testfile is present\n"; } else { $check = 1; $msg1 = "testFile Is Not Avaliable. $timex"; $subj1 = "testFile Is Not Avaliable "; insertlog($msg1); maildl( $msg1, $env, $subj1, $maillst ); last; }

That's just cutting and pasting your code and running it through perltidy. At least now we have a vague idea of what your code looks like. And as it stands, the last isn't necessary -- there's no loop to break out of.

But if there's more to your code, show it to us. Better than that, of course, would be the smallest possible example where the Weird Behaviour is still seen. That way we don't have to paw through dozens (or hundreds) of lines of irrelevant code.

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds