#!/usr/bin/perl -w use strict; my $file = shift @ARGV; # open the file for reading open( INFILE, "$file" ) or die "Couldn't open $file for reading: $!\n"; # slurp the file # I hate to do this, but the tags we're looking for span lines at random my $fileString = do { local $/; }; close(INFILE); # open the new file for writing open( OUTFILE, "> $file.new" ) or die "Couldn't open $file for writing: $!\n"; # look for image maps $fileString =~ s/(

.*?)/\n

$1\n<\/div>/igs; print OUTFILE $fileString; close(OUTFILE);