On Wed, 5 Dec 2001, Daniel Falkenberg wrote:

> Please don't stree to much over this one but, is there an easier way of
> writing this?
>
> while(1){
>   if ($status == 1) {
>     #Do this sub...
>     sub();
>   elsif ($status == 1) {
>     #Do this other sub...
>     sub2();
>   } else {
>     #Continue while loop...
>   }
> }

I would use the Perl equivalent of a switch statement:

SWITCH: for($status) {

        /^1$/ && do { sub(); last SWITCH };
        /^2$/ && do { sub2(); last SWITCH };

        print "Invalid value for $status\n";
}

perldoc -q switch

-- Brett
                                          http://www.chapelperilous.net/
------------------------------------------------------------------------
Paradise is exactly like where you are right now ... only much, much better.
                -- Laurie Anderson


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to