#!/usr/bin/perl

if ($ARGV[0] eq "")
{
	die "Usage: xhtml.pl HTML_file";
}
else
{
	$fileName = $ARGV[0];
}

open (FILE, "<$fileName") || die "file couldn't be opened for reading $!";
@data = <FILE>;
close (FILE);

foreach $line (@data)
{
	#find <img> <br> <hr> or <input> tags and make sure there is a closing slash
	#if there isn't a slash add one

	#assume there is only one tag per line
	
	#for an extra challenge (attempt it after you get it working) try to make it just one statement :)
}

$fileName =~ s/(.*)\.(.*)/$1\.new\.$2/i;

#write the finished file back out.
open (FILE, ">$fileName") || die "file couldn't be opened for writing $!";

#one way to write to the file
#foreach $line (@data)
#{
#	print FILE $line;
#}

#the shorter way to write to a file
print FILE @data;

close (FILE);