On Sunday 09 May 2010 08:43:52 Xiao Lan (小兰) wrote:
> On Sun, May 9, 2010 at 1:07 PM, John W. Krahn <jwkr...@shaw.ca> wrote:
> > Just remove the foreach statement modifier:
> > 
> > print $fd @x;
> 
> Thanks John.
> If @x is as large as 1000+ elements, should I do this print still?

I believe that << print {$fd} @list; >> does not concatenate all the arguments 
into one big string and then prints it (similar to << print {$fd} join("", 
@list); >>) but rather prints them one after the other (and even with printing 
strings, there may also be buffering issues and other stuff like that - look 
at http://perldoc.perl.org/functions/syswrite.html if you want to avoid that).

If you're still unsure, use Benchmark.pm to see which one is faster. But 
remember that it's not a good idea to optimise your program prematurely. Did 
you run into a specific problem with using << print {$fd} @list; >>?

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
The Case for File Swapping - http://shlom.in/file-swap

God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to