develooper Front page | perl.perl5.porters | Postings from February 2008

Re: [perl #50742] goto error?

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
February 12, 2008 03:42
Subject:
Re: [perl #50742] goto error?
Message ID:
47B18605.2070102@pobox.com
深沢千尋 (via RT) wrote:
> I'm afraid there's something wrong in the goto parsing of Perl.
> Please kindly confirm.
> 
> When I run the program below;
> 
> 	#! /bin/perl -w
> 	# gotoTest.pl
> 
> 	goto FIN if 1;
> 
> 	print "skipped \n";
> 	&sub_routine;
> 
> 	FIN:
> 
> 	sub sub_routine {
> 		print "skipped 2\n";
> 	}

Labels (what FIN is) must be attached to a block or statement.  They can't 
just be floating out there alone and they don't work on subroutines.

To DWIM you would want FIN: 1;

Or do the world a favor and don't use goto. :)


-- 
The interface should be as clean as newly fallen snow and its behavior
as explicit as Japanese eel porn.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About