in reply to How it works?

This

sub rand_elt { $_[rand @_] }

is a terse version of that:

sub rand_elt { my @keys = @_; my $num_keys = scalar @keys; my $random_index = int( rand($num_keys) ); return $keys[$random_index]; }

In my experience, writing a nifty condensed sub like the one below "This" will gain you the questionable reputation of writing "write-only code" at your company or elsewhere, among those which aren't familiar neither with the concepts of perl nor with the language in general. Best is to endure such as camels do - with some sort of सच्चिदानन्द at the beast level for starters, or higher.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: How it works?
by Your Mother (Archbishop) on Jan 21, 2016 at 00:34 UTC

    Your explanation is perfect—aces—but I assert that $array[rand@array] is a perfectly cromulent Perl idiom and if we are writing our Perl code for Pythonistas, PHPeepers, Javatards, and Ruby fanbois… That sucks the love of being JAPH right out.

      Assertion approved. I've been working at a shop where coding standard demanded me to write perl like shell, and worse. No (key => $value) x !! $flag in hash constructors, no statement modifiers, no nested expressions like $array[rand@array] and else. Never, ever, unless. Yuck.

      perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'