#! perl\bin\perl use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); open(FILE, "< file1.html") || print "Unable to open the file file1 \n"; while () { if($_ =~ /on\.fe/) { my $url = $_; print $mech->uri."\n"; $mech->get($_); $mech->content(); if($mech->content()=~ /www\.arax/) { my $url2 = $mech->content() =~ /www\.arax/; print $mech->uri."\n"; s/$url/$url2/; print; } } } close(FILE);