http://qs321.pair.com?node_id=27514

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I print a quotation-mark?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do I print a quotation-mark?
by merlyn (Sage) on Aug 11, 2000 at 17:56 UTC
    For all stringish things, putting a backslash in front of the closing delimiter reduces it to ordinary character status:
    my $string = "He said, \"That's a lie!\"";
Re: How do I print a quotation-mark?
by turnstep (Parson) on Aug 11, 2000 at 21:16 UTC
    Use some other string delimter, such as single quote (') or qq (as in qq(...) or qq/.../):
    print qq[And vroom said "Let there be nodes!" and there were nodes.\n] +;
    Use a "here-document" syntax:
    print <<"WALDO"; "Where is Waldo?" asked the creature? It replied "On the next line!" WALDO
Re: How do I print a quotation-mark?
by nardo (Friar) on Aug 11, 2000 at 21:01 UTC
    You could also enclose it in single quotes.
Re: How do I print a quotation-mark?
by toolic (Bishop) on Aug 19, 2009 at 17:27 UTC
    If you just need a quote character all by itself, you can make one using the chr function: Use the ASCII code for the double quote character ("). With chr:
    print chr(34); my $quot = chr(34); print "This is ${quot}not$quot a quote.\n";

    Use the octal or hexadecimal escape code:

    print "\042"; print "\x22";