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

I'm trying to add the nofollow tag to my script but the " symbols in the rel="nofollow" part of the link are being rewritten in the HTML as " like this:
<a href="http://www.example.com/ rel=&quot;nofollow&quot;">http://www +.example.com/</a>

Instead of:
<a href="http://www.example.com/ rel="nofollow">http://www.example.co +m/</a>


Here's my code:
$page_link = a ({-href => "$val[5]  rel=\"nofollow\""}, $linktext);

Anybody know what the syntax is to keep the " symbols intact?

Many thanks in advance,

Replies are listed 'Best First'.
Re: rel="nofollow" tag syntax?
by Corion (Patriarch) on Apr 17, 2007 at 12:07 UTC

    Don't try to put stuff into the href attribute when it should go into the rel attribute:

    perl -MCGI=a -e "print a({-href=>'http://perlmonks.org',-rel=>'nofollo +w'},'PerlMonks')"
      Thanks Corion. Can you please tell me what -MCGI means? I tried putting your code in, but it just wiped out the link completely - obviously, I'm doing something wrong. Thanks again, -Bob

        corion is using a one-liner that is run through the Perl interpreter. So the -MCGI means to load the CGI module for this one-line program.

        The code was not meant to be placed wholly into your code, it is just a quick way of showing how that one-line should work.