From daily-tips@perl.org. Might be worthwhile adding this as a resource to the learning perl section on.
Thoughts?
We are at the Perl Conference in San Diego having lots of fun and
learning lots of cool new stuff. Be sure to follow the coverage at
http://use.perl.org/ and http://www.perl.com/ :-)
On to the tip: Anyone have seen code like
print "<a href=\"http://$url/\">$site</a> (\"$title\")";
Now, it is quite annoying to read all those \'s, so you would think
there is a better way.
Well, there is! :-)
The above line could be written as
print qq[<a href="http://$url/">$site</a> ("$title")];
So instead of using " as the quote operator we used qq[ and ] to end
the quote.
You can also use for example qq{ (or any other form of "brackets"), li
+ke
print qq{...};
Like "text" can be substituted with qq[text] you can use a single q
for ', so a confusing statement like
'\'daily-tips-subscribe@perl.org\''
can be written as
q['daily-tips-subscribe@perl.org']
instead.
For more information, run "perldoc perlop" and search for "Quote and
Quote-like Operators".
To unsubscribe: mail daily-tips-unsubscribe@perl.org
To subscribe: mail daily-tips-subscribe@perl.org
Or visit: http://learn.perl.org/tips/
Comments, suggestions? Send them to ask@perl.org.
"The future will be better tomorrow."
... from the collected wisdom of George W Bush.
Edit Masem 2001-07-27 - CODE Tags