in reply to Re: Re: Not Using So Many 'if' Statements
in thread Not Using So Many 'if' Statements

Right... last will break me out of my loop... but why not just exit as soon as I've accomplished the purpose of the script instead of adding an extra command?

Update: Here's what I mean:
Adding the last statement would require an additional conditional:
my $success; for(@host){ $stout = run($_); unless($stout == 256) { $success++; last; } print "$_ not responding, trying next host\n"; } print "all hosts not responding" unless $success;

Replies are listed 'Best First'.
Re: Re: Re: Re: Not Using So Many 'if' Statements
by CountZero (Bishop) on Jan 09, 2003 at 20:46 UTC

    Indeed, no reason why you should not use exit to kill the program if you're done. I was just pointing to the side-effects of exit: you may get more more than you bargained for.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law