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

going nowhere fast

Tom Christiansen
March 22, 2000 09:47
going nowhere fast
Message ID:
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About