DigitalKitty has asked for the wisdom of the Perl Monks concerning the following question:
#!/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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: Pretty cool link extractor.
by jeffa (Bishop) on Mar 26, 2002 at 00:51 UTC | |
by gav^ (Curate) on Mar 26, 2002 at 04:23 UTC | |
|
Re: Pretty cool link extractor.
by shotgunefx (Parson) on Mar 26, 2002 at 00:54 UTC | |
by Util (Priest) on Mar 26, 2002 at 18:05 UTC | |
|
Re: Pretty cool link extractor.
by jeffenstein (Hermit) on Mar 26, 2002 at 07:03 UTC | |
by DigitalKitty (Parson) on Mar 26, 2002 at 20:38 UTC |