#! /usr/bin/perl # Fix-camwest-pages.pl # To automate the editing of CAMWEST web pages to # remove the old table-based layout, replace with new CSS based layout. # Also replace old menu with new dynamic CSS menu. # CAMWEST web site is at http://camwest.pps.com.au/ # foreach html file, if there is no .shtml file, # 0. slurp old html file into memory since some tags are multiline. # (no html files on the site challenge RAM in this machine) # 1. read memory string, from the
extract: # a.(?:\ )?\s*
\s*}{}gxms; } return unless $first_header and $content; return ( $first_header, \$content ); } sub write_using_template($$$$\$@) { my ( $output_filename, $template_filename, $title, $first_heading, $content_ref, @meta ) = @_; ### print "TITLE='$title'\n"; ### print "META='@meta'\n"; ### print "FIRST_HEADING='$first_heading'\n"; ### print "CONTENT=\n'$$content_ref'"; die "WAS ABOUT TO CLOBBER '$output_filename'\n" if -e $output_filename; open my $template_fh, '<', $template_filename or die "Unable to open template file '$template_filename'\n: $!"; open my $shtml_fh, '>', $output_filename or die "Unable to write to '$output_filename': $!"; my $meta = join "\n ", @meta; while ( <$template_fh> ) { s{__META__}{$meta}xms; s{__TITLE__}{$title}xms; s{__FIRST_HEADER__}{$first_heading}xms; s{__MAIN_BODY__}{$$content_ref}xms; print $shtml_fh $_; } } sub check_ok($$$) { my ( $name, $var, $file ) = @_; warn "$name is empty in file '$file'\n" unless $var; } sub usage() { ( my $prog = $0 ) =~ s{^.*/}{}xms; print <