I have an issue with people who insist on using <"> as a string delimiter when the (static) string itself contains that very character. It gets fugly all too soon:
my $html_output = "<a href=\"http://www.example.com/foobar/$pagename.html\" title=\"Oh, a link to $pagename\"> ...\n";
It's so easy to avoid having to quote the <"> while still allowing variable interpolation:
my $html_output = qq(<a href="http://www.example.com/foobar/$pagename.html" title="Oh, a link to $pagename"> ...\n);
Since the example is HTML (and could be e.g. SQL), and it might be multi-line, why not ...
my $html_output = <<EOL;
<a href="http://www.example.com/foobar/$pagename.html"
title="Oh, a link to $pagename>
EOL
That wasn't so hard? Or fugly?
4 comments:
Agreed.
I never bothered to learn to remember qq; maybe I will now. Thanks!
Same goes for people who say /\/usr\/bin/ instead of m{/usr/bin}.
I agree too
Post a Comment