[Israel.pm] One-liner perl question

Assaf Gordon gordon at cshl.edu
Tue Sep 11 07:23:35 PDT 2012


Assaf Gordon wrote, On 09/11/2012 09:54 AM:
> Avishalom Shalit wrote, On 09/11/2012 03:39 AM:

>> b- perhaps he had a secret part of a program in perl, to which he
>> wants to pass an array other than @ARRRRGGV me hearties
>>
>> c- i really hope that this was an exercise although my favorite bit of
>> perl (written by someone else) is a beautiful dispatch sequence that
>> read like a poem
>>
> 
> I can't argue about beauty, poems, and secrets desires... 
> Technically, I think the shell command answers his request, in a form that is shorter (that's a fact) and cleaner (that's my opinion) than the Perl code.
> 

Here's another solution, even shorter (if you're willing to accept mixing ls, shell pipes and perl):
===
ls | perl -sne '$a{length($_)}=$_;END{map{print $a{$_}}(1..$N+1)}' -- -N=5
===


-gordon


More information about the Perl mailing list