"Bob Showalter" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Jennifer Garner wrote: > > Hi,lists, > > > > I have a small script,when it run,it generate much more lines and put > > them > > into a file. > > The code for printing I writed: > > > > map { print RESULT $_,":",$ips{$_},"\n" } > > sort { $ips{$b} <=> $ips{$a} } keys %ips; > > I would write it like this: > > print RESULT "$_:$ips{$_}\n" > for sort { $ips{b} <=> $ips{$a} } keys %ips; >
For small hashes, I might use: print RESULT map { "$_:$ips{$_}\n" } sort { $ips{$b} <=> $ips{$a} } keys %ips; This only calls print() once. For big hashes I would probably use Bob S's solution. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>