ents : String Between <A></A> Tag 	    			 ----#

sub get_anchor_tag ($)
{
	my $anchor = shift;
	my $tag = undef;
	my $img_tag = undef;
	my $temp = undef;

	#---- Check whether There Is Any <IMG> Tag In String ----#	

	if ($anchor =~ /(.*?)<\s*img(.*?)>(.*?)<\s*\/img\s*>(.*?)/i)
	{

		#---- Featch "SOURCE" And "ALT" From It ----#

		$img_tag = $2;
		if($img_tag =~ /(.*?)alt\s*=\s*\"(.*?)\"\s*(.*?)/i)
		{
			$tag = $2; # Assign "ALT value" As TAG
		}elsif($img_tag =~ /(.*?)src\s*=\s*\"(.*?)\"\s*(.*?)/i)
		{
			$tag = $2; # Assign "SRC value" As TAG	
		}
	}

	while ( $anchor =~ /\s*<\s*(.+?)\s*(.*?)\s*>\s*(.*)\s*<\s*\/\1\s*>\s*/i )
	{	
		$anchor = $3;
	}

#---- If There Is Any Title Return It Else Return Tag ----#

return $anchor unless($anchor =~ /^\s*$/);
return $tag;

}		 

 "<title>Directory tree : $dir </title>\n";
print OUT "<meta content = \"text/html; 
	   charset = iso-8859-1\" http-equiv = Content-Type>\n";
print OUT "</head>\n";
print OUT "<body>\n";
print OUT "<pre>\n";

#---- Generate tree ----#

print OUT "$dir\n";
($dc, $df) = tree_gen($dir, "");

#---- Print Directory and File count ----#

print OUT "\n$dc Directories,  $df Files";

#---- Complete The HTML File ----#

print OUT "</pre>\n";
print OUT "</body>\n";
print OUT "</html>\n";

#---- End Of Main ----#

#---- Subroutine : tree_gen - Recursive Function To Generate Tree ----#
#---- Arguements : <Directory to be parsed> <String to be appended> ----#

sub tree_gen($$)
{

#---- Variables ----#

my ($dc,$df,$count,$t1,$html,$title,$c,$tag,$link);
my ($next,$nextname,$dir_count,$file_count,$curdir,$str); 
my (@files,@ignore);

#---- Initialize The Variables ----#

$curdir = shift;
$str = shift;
$next = ""; 
$nextname = "";
$dir_count = 0; 
$file_count = 0; 

#---- Browse Through The Directory ----#

opendir CURDIR, "$curdir" or die "Could not open $curdir: $!";
@files = grep !/^\.\.?$/, readdir CURDIR;
closedir CURDIR;
$count = $#files + 1;

#---- Iterate Through All Files And Generate Tree 
#---- Make Recursive Calls, If Necessary ----#

foreach $next (@files)
{	
	#---- Count To Check Whether The FILE is LAST or NOT ----#
	
	$count -= 1;
	
	#---- Check For Files And Take Appropriate Action ----#
	
	#---- Directory? - Make Recursive Call ----#
	
	if( -d "$curdir/$next" ) # Directory?
	{
		$dir_count += 1; 
		if($count>0)
		{	
			print OUT "$str|--$next\n";
			($dc,$df) = tree_gen("$curdir/$next", "$str" . "|\t");
		}
		else # Last File
		{	
			print OUT "$str`--$next\n";
			($dc,$df) = tree_gen("$curdir/$next", "$str" . "\t");
		}
		$dir_count += $dc;
		$file_count += $df;
	}#---- HTML? Find TITLE And ANCHOR Tag ----#
	elsif($next =~ /.*\.html?$/i ) # HTML file?
	{
		$file_count += 1;
		open(HTML,"$curdir/$next")||die "Could not open $next $!";
		$html = "";
			
		#---- Get HTML File In A String For Efficient Comparision ----#
		
		while(<HTML>)
		{
			chomp; # Get Rid Of "\n", Tags May Spans Multiple Lines
			$html = "$html" . "$_";
		}

		#---- Get Title Of The Page ----#

		if($html =~ /.*?<\s*title\s*>\s*"?(.*)"?\s*<\s*\/title\s*>.* /i)
		{
			$title = $1;
		}else
		{
			$title = $next;	#Tilte Not Specified, Use File Name
		}
		$c = 0;	
		if($count>0)
		{
			print OUT "$str|--<a href = $curdir/$next>$title</a> ($next)\n";
		}
		else	# Last FIle 
		{
			print OUT "$str`--<a href = $curdir/$next>$title</a> ($next)\n";
		}
		
		#---- Get Anchor Tags Of The Page ----#

	 	while ($html =~ /.*?<\s*a\s+name\s*=\s*"?(.*?)"?\s*>\s*(.*?)\s*<\s*\/a\s*>.*?/ig)
		{
			$c += 1;
			($tag,@ignore) = get_anchor_tag ($2);	
			$link = $1;
			$tag = $link if($tag =~ /^\s*$/);
			if($count>0)
			{
			print OUT "$str|\t`--<a href = $curdir/$next#$link>$tag</a>\n";				
			}
			else
			{
			print OUT "$str\t`--<a href = $curdir/$next#$link>$tag</a>\n";				
			}
		}		 
	}
	else #Everything else - Other Files 
	{
		if($count>0)
		{	
			print OUT "$str|--$next\n";
		}
		else 	#Last File
		{	
			print OUT "$str`--$next\n";
		}
		$file_count += 1; 
	}	
}

return $dir_count, $file_count;	

}

#---- Subroutine : get_anchor_tag - Function To Find Title-tag For Anchor----#
#---- Arguem