in reply to Writing to a file: problem
This way you're writing to the output file as you're modifying the data from the input file (not the input file itself) and once that's finished you replace the input file with the output file.my $path = "E:/Documents and Settings/Richard Lamb/My Documents/HTML"; open INFILE, "$path/dummy.html" or die "$!: Can't open this file"; open OUTFILE, ">$path/new_dummy.html" or die "$!: Can't write to the HTML file"; while (<INFILE>) { s/(<h[1-6]\s+style=.*)">/$1; word-spacing: 50px">/ig; s/(<li\sstyle=.*)">/$1; word-spacing: 20px">/ig; s/(<p style=.*)">/$1; word-spacing: 20px">/ig; print OUTFILE $_; } close INFILE; close OUTFILE or die "$0: $!"; rename "$path/new_dummy.html", "$path/dummy.html" or die "$0: $!";
See. open, perlopen and rename for more info on the functions used.
HTH
_________
broquaint
|
|---|