Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Aharrr!

by benn (Priest)
on Sep 17, 2003 at 15:00 UTC ( #292135=obfuscated: print w/ replies, xml ) Need Help??

Avast ye scurvy lubbers! Thanks to the efforts of Cap'n Martin, this here be code to remind thee that Friday is International Talk Like A Pirate Day. Yarrr!
use Acme::Lingua::Pirate::Perl; $treasure=<<"Harrr!"; It seemed 'twas just going to be another day writing more Perl ,when suddenly... a PIRATE! .... Harrr! steal @{(map {"of"} the treasure)}; open chest; Yarr!; our @share = split(/$shipmates /,$treasure); while (the gold = plunder @share) { squint at the doubloons; curse Davy Jones' Locker if the doubloons be puny("amounts"); unless (++ a hornpipe %4) { Shiver me timbers! the booty = reverse split(/$shipmates/,puny(the gold)); Avast! thrust the treasure, vast(hurl the booty); cry join ($shipmates,reverse the treasure)," ";}} close chest; Arrrr! yell Splice the mainbrace! and sail off; Yo ho ho!
Now - where's that rum?

Blackhearted Ben.

Comment on Aharrr!
Download Code
Re: Aharrr!
by PhilHibbs (Hermit) on Sep 17, 2003 at 15:58 UTC
    Okay I think I've worked out the basic structure. The heredoc gets split into an array of words, then every fourth word (the %4) is printed - puny and vast are Pirate for lc and uc, so the fourth words "just another Perl PIRATE" get re-cased and printed. I'm not sure what "squint at the dubloons" (Pirate for "study $_") does. I'm sure I've read about study somewhere, but perldoc doesn't know anything about it. Something to do with optimising a regex?
      I'm not sure what "squint at the dubloons" (Pirate for "study $_") does.
      Indeed, study looks at a string and indexes the chars for later regex use - pretty much made redundant by qr though. Here though, it's simply decoration. :)

        study and qr are not the same thing at all. qr compiles a regex string into the data structure that represents that regex in memory. study processes a string that a regex is going to process later. So the difference is that qr speeds up the regex on the right side of =~ and study speeds up the string on the left side.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: obfuscated [id://292135]
Approved by herveus
Front-paged by herveus
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (12)
As of 2014-11-27 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (187 votes), past polls