#!/usr/local/bin/perl
##############################################################################
#
# File:		link-finder.pl
# Purpose:	finds and prints all of the NAME, HREF and SRC statements
#		in an HTML document.
#
##############################################################################

while($file=shift(@ARGV))
{
	open(FILE,"<$file") || die, "Can't open file \"$file\": $!\n" ;

	#turn the file into a character string with no embedded \n's
	@document =  <FILE> ;
	$document =  join("",@document) ;
	$document =~ s/\n//g ;

	# process all of the HREFs
	$temp = $document ;
	while ($temp =~ /<A\s*HREF\s*=\s*([^>]*)>/i)
	{
		print "$file: HREF=$1\n" ;
		$temp = $' ;
	}

	# process all of the SRCs
	$temp = $document ;
	while ($temp =~ /SRC\s*=\s*([^>]*)>/i)
	{
		print "$file: SRC=$1\n" ;
		$temp = $' ;
	}

	# process all of the NAMEs
	$temp = $document ;
	while ($temp =~ /<A\s*NAME\s*=\s*([^>]*)>/i)
	{
		print "$file: NAME=$1\n" ;
		$temp = $' ;
	}

}

