Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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)

Replies are listed 'Best First'.
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 Quoutes
by mirod (Canon) on Jun 04, 2001 at 16:52 UTC

    There are plenty of ways, here are some:

    • using print a( {href => "$link"}, "foo");
    • using alternate delimiters: print qq{ <a href="$foo">foo</a>};
    • the dirtiest: print '<a href="', $link, '">foo</a>';
Re: Double Quotes
by one4k4 (Hermit) on Jun 04, 2001 at 16:49 UTC
    print "<a href=\"\">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 - (

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

      print qq(a href="">Perlmonks</a>);

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

      fyi, It's called "escaping"
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://85452]
Approved by root
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: (3)
As of 2020-09-24 00:02 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.