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

Re: [FWP] passwd file fwacking



>	my %passwd = map { $_->[0] => $_ } map { [ split /:/ ] }
>		IO::File->new("<$passwd")->getlines;
>	my %shadow = map { $_->[0] => $_ } map { [ split /:/ ] }
>		 IO::File->new("<$shadow")->getlines;
>	$passwd{$_}->[1] = $shadow{$_}->[1] for keys %passwd;
>	print join(':', @{$_}) for values %passwd;

Speed up your program with a unary + and map(EXPR,LIST):

  my %passwd = map +($_->[0] => $_), map [ split /:/ ],
    IO::File->new("<$passwd")->getlines;
  my %shadow = map +($_->[0] => $_), map [ split /:/ ],
    IO::File->new("<$shadow")->getlines;

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy@pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe