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;


Certainly, I can write that code with foreach style.
I want to know which method is more effective between foreach and map?

I don't know without benchmarking, but map() is typically used to build
a resulting

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to