I am using a snippet of code in a reciprocal-link script that detects (using LWP) if the page still has a link to my site.
Here is the code snippet:
foreach (split(m!\<A!i, $text)) {
next unless (m!^([^\>]*)HREF(\s+)?=(\s+)?\"?([^\"\s\>]+)!i);
$ThisLink = $4;
$reciprocal = "no";
if ($ThisLink =~ /^http\:\/\// ){
if ($ThisLink =~ /^http\:\/\/www\.widget\.com/ ){$reciprocal = "yes";}
}
} # END foreach
This above code works good to detect the reciprocal link
BUT Some webmasters afterwards add the "class=external" code, so that the link becomes of No PR value.
I want to detect if the word "external" is present in the <a>...</a> link and therefor have changed my code, BUT it does not work.
Changed code:
foreach (split(m!\<A!i, $text)) {
next unless (m!^([^\>]*)HREF(\s+)?=(\s+)?\"?([^\"\s\>]+)!i);
$ThisLink = $4;
$reciprocal = "no";
if ($ThisLink =~ /^http\:\/\// ){
if ($ThisLink =~ /^http\:\/\/www\.widget\.com/ ){
if ($ThisLink =~ m/external/i){$reciprocal = "external";}
else {$reciprocal = "yes";}
}
}
} # END foreach
Any help would be appreciated
http://www.widget.com. Try changing:
if ($ThisLink =~ m/external/i){$reciprocal = "external";} to:
if (m/external/i){$reciprocal = "external";} Still, that looks like just part of the problem. Should
$reciprocal = "no"; be moved above the foreach?