Re: goto command
The reason why the goto command is not generally used in perl (and other languages) is that it does not force the developer to have a theoretical framework for the program. It creates 'spagetti code' where a person working on the code or trying to understand what the developer has done has to follow a rabbit tunnel of goto directions. A direct alternative is using sub procedures which not only perform the same goto like movement, but can use parameters and return values as well. Thomas Browner [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Thanks, Thomas Browner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: goto command
For Quality purpouses, Thomas Browner 's mail on Thursday 29 January 2004 18:46 may have been monitored or recorded as: Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Not talking about style (but in the TIMTOWTDI spirit): from perldoc -f goto: goto LABEL goto EXPR goto NAME The goto-LABEL form finds the statement labeled with LABEL and resumes execution there. It may not be used to go into any construct that requires initialization, such as a subroutine or a fore- ach loop. It also can't be used to go into a construct that is optimized away, or to get out of a block or subroutine given to sort. It can be used to go almost anywhere else within the dynamic scope, including out of subroutines, but it's usu- ally better to use some other construct such as last or die. The author of Perl has never felt the need to use this form of goto (in Perl, that is--C is another matter). (The difference being that C does not offer named loops combined with loop control. Perl does, and this replaces most structured uses of goto in other lan- guages.) hth, wolf -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: goto command
Thomas Browner wrote: Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Yes. But I've never seen a case where I think it should be used. Perl isn't a scripting language. (Although it can be, just like it can be most things.) If you want help, then please explain what you're trying to do. Then we will explain how. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: goto command
Sub dothissubroutine { Do something If return this Else return this } My $result = dothissubroutine If $result = this }elsif This }else{ This } Paul Kraus --- PEL Supply Company Network Administrator -Original Message- From: Thomas Browner [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 12:46 PM To: [EMAIL PROTECTED] Subject: goto command Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Thanks, Thomas Browner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: goto command
Why not just make it a sub, so you perform the sub and continue on from there: if ( sub1() ) { # return of true sub2(); }else { # return false, so do something else or nothing } Wags ;) -Original Message- From: Thomas Browner [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 09:46 To: [EMAIL PROTECTED] Subject: goto command Does perl have a goto command. For example if you tell scrip to do something and it returns a 1 then it should go to a block of code that does something else. Thanks, Thomas Browner -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response