jonnyfolk has asked for the wisdom of the Perl Monks concerning the following question:
I started with a form which has a standard action when in receipt of standard parameters. I added a checkbox to the form to change the action. What I opted to do was the following:
Of course when I tried it all sorts of error messages came up, but unfortunately none of them said "Oi, plonker, you can't put a 'while' statement inside an 'if'"! So I battled away until I finally understood that for myself.if ($checkbox) { #open file while (<FILE)> { #do something } }
What I did do was whack the action into a subroutine and put that into the 'if' statement.:
My question is: are there other ways of making this work apart from a subroutine?if ($checkbox) { &dosomething; } } sub dosomething { #open file while (<FILE)> { #do something } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using loops inside an 'if' statement
by liz (Monsignor) on Oct 02, 2003 at 09:33 UTC | |
by jonnyfolk (Vicar) on Oct 02, 2003 at 10:27 UTC | |
|
Re: Using loops inside an 'if' statement
by thens (Scribe) on Oct 02, 2003 at 09:39 UTC | |
|
Re: Using loops inside an 'if' statement
by broquaint (Abbot) on Oct 02, 2003 at 09:33 UTC | |
|
Re: Using loops inside an 'if' statement
by davido (Cardinal) on Oct 02, 2003 at 09:33 UTC | |
|
Re: Using loops inside an 'if' statement
by thinker (Parson) on Oct 02, 2003 at 09:36 UTC | |
|
Re: Using loops inside an 'if' statement
by shenme (Priest) on Oct 02, 2003 at 15:06 UTC |