Re: [OT] Help with Perl Script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 21 April 2010 09:21, Dan Track <dan.track@xxxxxxxxx> wrote:
> Hi,
>
> I appreciate that this is off-topic and wholly understand if I don't
> get an answer, although one would really appreciate it if I do get an
> answer :)
>
> Basically to improve my perl scripting, I've given myself a challenge
> where I would like to order the users in the passwd file by uid,

You've already got plenty of good advice in this thread, but I thought
you might be interested in seeing just how short the program can be if
you use a lot of Perl's features.

  #!/usr/bin/perl

  use strict;
  use warnings;

  @ARGV = '/etc/passwd';

  print sort { (split /:/, $a)[2] <=> (split /:/, $b)[2] } <>;

I probably wouldn't use something _quite_ this cryptic in production code.

Cheers,

Dave...
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux