I would use HTML::TokeParser to pull the links out of your file and then modify them from there, like so
#!/usr/bin/perl -w use HTML::TokeParser; use strict; my $i=0; ## set marker definintions my @markers = qw/ anfnf11 iopi1p83288 9032-jjjf /; my $htmlfile = "index.html"; my $content; ## get contents of your html file open (FILE," $htmlfile") || die "Cannot open HTML file for parsing!: $ +!\n"; while(<FILE>) { $content .= $_; } close(FILE); my $parse = HTML::TokeParser->new(\$content); while (my $token = $parse->get_tag("a")) { my $url = $token->[1]{href} || "-"; ## put link into $url my $text = $parse->get_trimmed_text("/a"); ## put link de +sc into $text if ($markers[$i]) { print "<a href=$url/$markers[$i]>$text</a>\n"; } else { ## no more markers... } $i++; } exit;
-p
In reply to Re: appending a unique marker to each url in a file
by thatguy
in thread appending a unique marker to each url in a file
by cat2014
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |