Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Pe(a)rls in line noise

by liz (Monsignor)
on Sep 15, 2003 at 08:12 UTC ( #291510=note: print w/replies, xml ) Need Help??

in reply to Re: Pe(a)rls in line noise
in thread Pe(a)rls in line noise first attempt at decoding any JAPH...

Well, you're in good company then, because this was the first JAPH I ever made myself. Honest!

@; = (491036,8051555,4785250,3341086,912133,189089,691108);
Yep, that's just eye candy. There have been some JAPH's recently that used magical increment for an X number of times, and I was going for similarly looking numbers. The:
================================= ==================================
and at the end: x: are also just eye candy. I tried several Larry Wall quotes while building this japh, and the line with '=====' made it possible for me to easily switch between keys and value in the hash (change the space between the "==="'s to "=" and all keys are values and vice versa in the hash).

$:{do} = 'to';
was actually a kludge. Originally I had the "to do" exchanged in the quote. But I found the error in the quote too obvious.

eval '$:{q?'.$_.'?}=~s'.shift@; for keys(%;);
This actually works because whatever order hash keys have in a hash, the order returned by the "keys()" and "values()" functions is the same. And for some reason, I _had_ to put parentheses with keys() and values() because otherwise I was getting the warning that the call was ambiguous. That's still on my list to check out later.

$_ = qq{@{[@:{qw{ He didn't do it }}]}};
is what you call an interpolated anonymous hash slice ;-) Working from the outside in: the qq{...} creates an interpolated string, which will put spaces between the elements because $" was not changed. The @{...} dereferences an array reference. The [...] create a reference to an array. The @:{...} creates a hash slice on %:. And finally the qw{...} creates the array of keys for the hash slice.

...cause the print, exit, code will take over from there...

I don't know if that is what you meant to say, but after the "exit" there is no code to execute anymore. So the "x:" is never reached, it's just eye candy.


Replies are listed 'Best First'.
Re: Re: Re: Pe(a)rls in line noise
by Roger (Parson) on Sep 16, 2003 at 01:31 UTC
    Hi Liz, thanks for your reply and detailed analysis!

    The biggest benefit I got from this is the anonymous hash slice bit. Normally I would have written something that joins the values of a hash as

    $_ = join " ", map { $:{$_} } qw/ He didn't do it /;

    Now I have learnt an ideomatic way to do it. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://291510]
marioroy At a large firm, had to awaken a security guy a few times so that nobody would catch him sleeping.
marioroy On a large dairy farm, almost went off the road with a 10 wheeler from exhaustion. On the farm, almost went off the silo with a big tractor. At the Fransiscan monastery, almost slipped off the dome while painting it.
[marioroy]: In Saudi Arabia caught fire but didn't burn. I think angels exist.
Lady_Aleena clean up after dinner finally.
[Discipulus]: uch! so we are twice lucky to have MCE..;=)
[marioroy]: Working a midnight graveyard shift, on the way home ran out of gas. just 2 minutes later somebody stops with a small tank of gas. It's wierd. There's always someone nearby for some reason.
[Lady_Aleena]: I was the one who stop[ed in the middle of a cold night to pick up a small family walking to a gas station. I got a few gallons of free gas for the round trip, and the grandmother said she'd pray for me.
[marioroy]: Folks do not know it, but MCE was ridiculously difficult. At Niagra Falls, heard a voice on enabling Grace while in the mist boat. That 10x performance is possible.
[marioroy]: Lady_Aleena Angels on earth are real people. That's awesome.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-05-29 08:26 GMT
Find Nodes?
    Voting Booth?