By request... Don't read this if you want to figure the JAPH out for yourself!
$_ = $"; # copy $", which is a space, to $_, for convenience later $^ = A; # assign 'A', the first label, to $^ &{':'}; # use a symbolic reference to call the sub named : # this starts the process... (see below) sub AUTOLOAD { # the AUTOLOAD sub, called when an undefined subroutine is called print $AUTOLOAD =~ /:+(.?)/s; # $AUTOLOAD holds the name of the undefined subroutine, including +package # i.e. &J calls AUTOLOAD and sets $AUTOLOAD to 'main::J' # find the colons, match the next character, and print it # (when $AUTOLOAD ends in a colon, prints a null string) goto $^++; # goto the label specified by $^ # post-increment $^ for next time } # the rest of the script consists of labels and statements, # in some non-alphabetical order - that's okay, because # the goto calls are in alphabetical order # to make the code easier to follow I'll reorder it starting here &{':'}; # start the process by calling the sub : # a null string is printed, and goto jumps to label A A: &J; # label A: call the sub J # 'J' is printed, and goto jumps to label B B: &u; # label B: call the sub u # 'u' is printed, and goto jumps to label C # this continues for some time... E: &$_; # label E: call the sub [space] with a symbolic reference # ' ' is printed, and goto jumps to label F # etc... Z: &{$/}; # label Z: call the sub [newline] with a symbolic reference # "\n" is printed (thanks to the /s on the regex), # and goto jumps to label AA AA: rjk; # rjk is a bareword, not a subroutine call, # so the script ends

In reply to Re: (SPOILER) autogoto.pl by chipmunk
in thread autogoto.pl by chipmunk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.