Hi.

This is probably a question better asked to the perl monks or similar, but if there are any of them lurking around here, it would save me a subscription.

In various programs, I do a lot of printing, for results or for logging.
Really many print statements, in forms such as :

print OUT "$var1  some fixed string [$var2] another string\n";
OR
print OUT $var1,"some fixed string [",$var2,"] another string","\n";
OR
print OUT $var1 . "some fixed string [" . $var2 . "] another string" . "\n";
and other variations.

Some of these forms are easier to handle and type than others, depending a bit on circusmtances. In many cases for instance, $var1 above is always the same string (a prefix of some kind common to all print's or many of them in a row), but $var2 is different each time (both the specific variable and its content). The individual print statements cannot be grouped together as one print, they happen at different places/times.

Now, my question is, considering the way perl handles these things internally, how do these different forms compare in terms of eficiency ?

I would not ask, if there were not sometimes really many of these being executed over and over again. I figure it may be worth knowing if one of the forms above (or another one I haven't tried) is really better than others in the sense that it saves magabytes of memory or cumulated seconds of processing time.

Thanks in advance,
André

Reply via email to