#!/usr/bin/perl # change font sizes.plx # Program will read in an html file, change font sizes and print changes to DOD command screen. # 1. No need for file variable yet: open (INFILE, "<".$htmlFile) or die("Can't read source file!\n"); # 2. /font-size:\s*[0-9]+pt;?/ig use warnings; use diagnostics; use strict; # Declare and initialise variables. my @htmlLines; # Open HTML test file - forward slashes do not need to be escaped. open INFILE, "E:/Documents and Settings/Richard Lamb/My Documents/HTML/test1InLineCSS.html" or die "Sod! Can't open this file.\n"; # Assign to an array/list variable. @htmlLines = ; close (INFILE); changeFontSize(); # Alter attribute values sub changeFontSize { foreach my $line (@htmlLines) { $line =~ s/font-size:\\s*14pt;?/font-size:\\s*18pt;?/ig; # case insensitivity and global search for pattern } } printHTML(); # prints the reformatted HTML file in DOS window sub printHTML { for my $i (0..@htmlLines-1) { print $htmlLines[$i]; } }