[Israel.pm] One-liner perl question

Avishalom Shalit avishalom at gmail.com
Tue Sep 11 00:39:01 PDT 2012


a- you forgot the exclude files of duplicate length bit

also,
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

s.t. like
check_is_main_requested    and    serve_main
or
verify_this_other_thing    and     initiate_something
or
check_the_item    and   duplicate_the_item


etc. etc.
only more readable.
beauty.

it also goes well with perl's ability to write sentences
call_sub1 $with_var1 and do_this_other_thing @on_this_list

poetry i tell you.
-- vish



On 11 September 2012 02:55, Assaf Gordon <gordon at cshl.edu> wrote:
> Hi,
>
> On 09/09/2012 01:39 PM, ynon perek wrote:
>>
>> I'm trying to turn a short program into a one-liner. The program takes an argument "n" and prints the first n file names sorted by file name length, with no duplicates in length.
>>
>
> I know you've asked for a *Perl* one-liner, but since a recent suggested solution already "cheat" by using the shell to get the list of files, why not just do it entirely in using standard command line programs ?
>
> ==
> ## prints the top 5 longest file names, remove the "r" from sort to print the shortest.
> ls | awk '{print length($0), $0}' | sort -nru | cut -f2 -d' ' | head -n5
> ==
>
> Seems cleaner, and shorter than any Perl solution...
>
> -gordon
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl


More information about the Perl mailing list