#!/usr/bin/perl -w #Path to perl interpreter. use strict; #The strict pragma. my @link_array; #Declare an array named link_array. @ARGV = "test1001.html"; #The file on the 'command line'. while(<>) #Does the file still have content? { s/<(?:[^>'"]*|(['"]).*?")*>//gs; #Remove all HTML tags. s/^(\s+)//g; #Remove all leading whitespace. #If a match is found, add it to the end of the array. #The search is global and case-insensitive. push @link_array, $_ if(/^http:/gi); push @link_array, $_ if(/^ftp:/gi); push @link_array, $_ if(/^mailto:/gi); } #End of the while loop. open( FH, ">>links.txt" ); #Open the file links.txt for #appending. print FH @link_array, "\n"; #Write the links we found to #the file. close FH; #Close the file handle.