goto considered fun

nicholas on 2004-02-19T16:48:21

Over the weekend I wrote some perl. It was fun. I don't seem to do much of this - maybe I should do it more often.

Anyway, in my perl I used lots of gotos. It's the first time I've used goto in anger in perl. I've added goto to the C source more than once, but never in perl.

Anyway, thanks to goto I now have this nice, clear code structure where I make regular subroutine calls and returns (visualise this as up and down) and I use goto to jump sideways between different subroutines at the same level. Fun. I'm curious if this technique could be useful for Befunge to Perl translators.

Of course, some people claim that goto & isn't a real goto, but I don't listen to them. Unfortunately the subroutine exits using last didn't survive from the prototype into the CPAN version, but they were fun while they lasted.

All this nasty evil hackery was based on some very nice code by Ton Hospel.