Dotan Dimet wrote, On 09/11/2012 12:29 PM:
> On 09/11/2012 05:23 PM, Assaf Gordon wrote:
>>
>> 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
>> ===
>>
>>
> FINALLY, a one-liner that uses a perl flag other than -e!
"perl -lane" is my hero :)
>
> The big bug is it doesn't actually print the first N file names, it prints
> the file names with lengths between 1..N
> So if the shortest name is more than 1 character, or some slots are missing...
>
Darn! my bad.
I tested it in a directory that had file names in every length... testing FAIL
:)
-gordon
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl