open (FILE, $filename); while(){ # walk each file my $line = $_ ; chomp $line; #grabbing and printing everything between the body tags if (//i ... /<\/body.*?>/i){ # this is a body line # extract the body ##changing .html to .asp in the links if (grep(/href.*\.html/,$line)) { (my $newline = $line ) =~ s/\.html/\.asp/g; print OUTFILE $newline . "\n"; next; } $body_temp = $_; $body_temp =~ s/(.*?)\(.*?)\<\/body\>/$2/i; chomp($body_temp); $body = "$body_temp" ; # Write the body to the output file print OUTFILE $body . "\n"; } } close(FILE);