Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

how to put double quotes inside strings? (was: Double Quoutes)

by Anonymous Monk
on Jun 04, 2001 at 16:41 UTC ( #85452=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have been trying to get links to work in perl generated html pages, but it won't allow double quotes so I can't use links. Any suggestions??

Edit 2001-06-04 by mirod: changed the title

Comment on how to put double quotes inside strings? (was: Double Quoutes)
Re: Double Quotes
by boo_radley (Parson) on Jun 04, 2001 at 16:46 UTC
    Double quotes can be escaped or quoted inside of double quotes : print " she said \"hello, world!\"";.
    this also works with single quotes : print ' she said \'hello, world!\'';.
    for more info, see perlop manpage.
Re: Double Quotes
by one4k4 (Hermit) on Jun 04, 2001 at 16:49 UTC
    print "<a href=\"http://www.perlmonks.org\">Perlmonks</a>";
    Should work just fine. You have to add a \ to anything you want to print that would normally be in a perl statement. (For the life of me the word for the concept of \(something) wont come to me. Its on the tip of my tongue... It's Monday, I suppose.)

    _14k4 - webmaster@poorheart.com (www.poorheart.com)

      Or, of course, you can use alternative quoting operators to remove the need to use ugly escaping characters.

      print qq(a href="http://www.perlmonks.org">Perlmonks</a>);
      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

      fyi, It's called "escaping"
Re: Double Quoutes
by mirod (Canon) on Jun 04, 2001 at 16:52 UTC

    There are plenty of ways, here are some:

    • using CGI.pm: print a( {href => "$link"}, "foo");
    • using alternate delimiters: print qq{ <a href="$foo">foo</a>};
    • the dirtiest: print '<a href="', $link, '">foo</a>';
Re: how to put double quotes inside strings? (was: Double Quoutes)
by fenonn (Chaplain) on Jun 04, 2001 at 18:14 UTC
    Just place the \ character before any " that is part of your data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://85452]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2015-07-06 21:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (83 votes), past polls