|
|
| Think about Loose Coupling | |
| PerlMonks |
Proper way to print a large number of stringsby jpfarmer (Pilgrim) |
| on Jan 07, 2003 at 14:38 UTC ( [id://224979]=perlquestion: print w/replies, xml ) | Need Help?? |
|
jpfarmer has asked for the wisdom of the Perl Monks concerning the following question: I'm using CGI.pm to write a CGI script and out of necessity, I have to do a lot of printing and I'm unsure of the best way to write it from a efficiency or style standpoint.
I ran a benchmark (output to the console, not to a browser) using this code:
And got these results:
It would seem, from this, that printing one line at a time is clearly most efficient, even though it had to loop through 10x more times. However, I don't know if that is conclusive, or if code efficency alone should dictate the style the program is written in. I have come for guidance: should I make each of my print statements its own line, should I join them with commas, or should I concatenate them as strings? I'm also willing to accept that it doesn't really matter at all. Thanks in advance.
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||||||