perl quotes in quotes

perl quotes in quotes
Option 1—escape ’em.
# quote characters same as the string delimiter
my $example = "Tried and \"true.\"";
my $triteness = 'Constant is constant and isn\'t edifying.';
Option 2—use the brilliant perl functions qq, q, qx, qw, qr, or <<; depending on what you’re trying trying to quote and how you’d like to do it.
# you can use almost anything for your quote delimiters
print qq/A "$variable" and newline!\n/, q(A real '$dollar sign.');
print <<''; Don't be a tricky bastard now! I won't stand for it.
print qx,/usr/bin/banner phat ashley,;
See the rest in the perldoc perlop. You should look at perldoc -f quotemeta too.
[close] Permanent link · http://querylog.com/q/perl+quotes+in+quotes

Suggested HTML for linking:
Link preview: perl quotes in quotes
14 July 2005 · Internet & computing
Browse by the page—15 Q&R each
« previous | more »