R. Joseph Newton wrote:
>
> > i.e.
> > print "Hello world";
> > if ($i == 50) {
> >     goto MAIN;
>
> Don't do this.  For some perverse reason, goto was included in the Perl
> language.  This may have been to support legacy programs.  No new code should
> ever be written with such structures.  They have been long since deprecated.

IMO that's a bit strong. 'goto' will always have its place until
language authors can predict all possible flows of control that
could be wanted by a programmer. Perl is richer than most in that
it has implicit gotos last, next, redo, return and die, but it
still has no try .. catch and many other things that I can't think
of now.

In the words of perldoc -f goto:

  It can be used to go almost anywhere else within the dynamic scope, including
  out of subroutines, but it's usually 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).

'Usually better' is different from 'deprecated' (and there are a
lot of deprecated constructs in Perl!)

Rob





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to