in reply to Re^3: rel="nofollow" tag syntax?
in thread rel="nofollow" tag syntax?

Thanks Herkum for the clarification. So then, there's no way to hack the code like I was trying to do? In order to insert the nofollow tag into the link, I have to use a module? Thanks again -Bob

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

    You already are using the CGI module, or something whose API is strikingly similar to the API of CGI.pm. Maybe you could just try out the example given to you to see whether it works for you or not. The following self-contained program works for me. Maybe it works for you too?

    use strict; use CGI qw(a); my $url = 'http://perlmonks.net/'; print a({-href => $url, -rel => 'nofollow'}, $url);

    If that still doesn't work for you, maybe you can show us the exact differences. If you need character-exact layout instead of what CGI.pm (or the module you're using whose API is similar to that of CGI.pm) provides you, then maybe one of the templating systems will do for you?

      Hi Corion,
      Got your code to work, sort of :-|
      Not sure why it's reversing the order of things and putting the nofollow before the href in the HTML:
      <a rel="nofollow" href="http://www.example.com/">http://www.example.com/</a>

      Here's what I put in:
      print a({-href => $val[5], -rel => 'nofollow'}, $linktext);

      Obviously I'm still messing something up in modifying the script:
      my $page_link; if ($val[5]) { # construct link if value is not NULL (undef) or empty my $linktext = $val[5]; $linktext = substr($linktext, 0, 27) . "..." . substr($linktext, - +10) if length($val[5]) > 40; $page_link = a ({-href => "$val[5]"}, $linktext);

      Thanks again,
        Hashes like that { -href => ..., -rel => ...} construct are unsorted. You can't rely on any specific order.

        Thankfully, HTML is the same in this regard. the order of attributes doesn't matter, so <a rel="nofollow" href="http://www.example.com/">http://www.example.com/</a> is completely equivalent to <a href="http://www.example.com/" rel="nofollow">http://www.example.com/</a>

      Thanks Corian.
      In php, all I have to do is:
      echo "<a href=\"{$row->URL}\" rel=\"nofollow\">".$row->URL."</a>";

      I'll try your code again and see if I can get it to work.
      Many thanks for the help,