$xml_hash($LinkToPage} = ($New_location); #### #!/usr/local/bin/perl use strict; use warnings; use HTML::TokeParser::Simple; my %xml_hash = ( 'link1.html' => 'linka.html', 'link2.html' => 'linkb.html', ); my $html_file = 'links.html'; my $p = HTML::TokeParser::Simple->new($html_file) or die "couldn't parse $html_file"; my $new_html; while (my $t = $p->get_token){ if ($t->is_start_tag('a')){ my $href = $t->get_attr('href'); if (exists $xml_hash{$href}){ $t->set_attr('href', $xml_hash{$href}); } } $new_html .= $t->as_is; } print "$new_html\n"; #### links

links

link1 link2 ##
## links

links

link1 link2