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

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?

Replies are listed 'Best First'.
Re^6: rel="nofollow" tag syntax?
by bobafifi (Beadle) on Apr 17, 2007 at 17:00 UTC
    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>

        Still not getting this :-|
        Is there a way that I can modify the line
        $page_link = a ({-href => "$val[5]"}, $linktext); without using the print function at this point in the script? Something like this perhaps? (but that works ;-)
        $page_link = a({-href => $val[5], -rel => 'nofollow'}, $linktext);


        Thanks,
        -Bob

        bobafifi.com
Re^6: rel="nofollow" tag syntax?
by bobafifi (Beadle) on Apr 17, 2007 at 16:02 UTC
    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,