[Israel.pm] A question of style - print()

Madani, Srikanth, VF-DE Srikanth.Madani at vodafone.com
Wed Oct 19 02:54:40 PDT 2005


Hi all,

I had the idea to replace a set of consecutive print statements with a
single call to print, spread over multiple lines. I think this will
improve readability. This is to be used when the consecutive print
statements are logically related. An illustrative example follows.

Before:

print "\n$0: Warning - couldn't find alias $emails in $EmailAliases";
print "\nAlias $emails cannot be resolved - no email will be sent.\n";
print "\nPlease contact file owner to update your desired group in
$EmailAliases.\n";


After:

print "\n$0: Warning - couldn't find alias $emails in $EmailAliases",
        "\nAlias $emails cannot be resolved - no email will be sent.\n",
        "\nPlease contact file owner to update your desired group in
$EmailAliases.\n";



(The leading whitespace in the second two lines of "After" is a tab.)

Of course, I wouldn't group statements like:

print "\nProcess ding-dong ended at $time.\n";
print "\nProcess RPC23556Z has been invoked at $time\n";

as they seem to belong to different code fragments.

What do you think?

Regards,
Srikanth Madani

That is the true season of love, when we believe that we alone can love,
that no one could have loved so before us, and that no one will love
in the same way as us.
                -- Johann Wolfgang von Goethe




More information about the Perl mailing list