in reply to Ignoring case
I think everyone would agree that only using one variable to manipulate one line of text makes things much clearer.#!/usr/bin/perl -w use strict; my $filename = './index.html'; open (FILE, $filename); open OUTFILE, '>out.asp'; while(<FILE>){ # walk each file chomp; #grabbing and printing everything between the body tags if (/<body.*?>/i ... /<\/body.*?>/i){ # this is a body line # extract the body #changing .html to .asp in the links if (/href.*\.html/i) { s/\.html/\.asp/gi; } s/(.*?)\<body\>(.*?)\<\/body\>/$2/i; # Write the body to the output file print OUTFILE "$_\n"; } } close(FILE); close OUTFILE;
Rich
|
|---|