develooper Front page | perl.perl5.porters | Postings from March 2000

going nowhere fast

From:
Tom Christiansen
Date:
March 22, 2000 09:47
Subject:
going nowhere fast
Message ID:
5710.953747224@chthon
I find it odd that

    goto "";

is allowed, and takes you nowhere, but that

    goto undef;

aborts saying goto needs a label.  Seems to me that
the former should do the same thing as the latter.

If someone is relying upon this for a state machine, though,
if it were "fixed", then they'd have to change

    goto fn();

to be 

    goto $label   if length($label = fn()) || !defined $fn;

Of course, you don't really want to do it if undef, but I'm just
showing how to preserve duplicate funcionality.  The current
version excepts on undef, and does nothing on "".

--tom



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