#!/usr/bin/perl -w use strict; use BuildLink; my $file = "/www/htdocs/shock/history.php"; my @words = buildLinks($file); print @words; #### package BuildLink; use strict; use Exporter; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = (); @EXPORT_OK = qw(&buildLinks); %EXPORT_TAGS = ( DEFAULT => [qw(&buildLinks)]); my @linkedFile = buildLinks(@_); return @linkedFile; sub buildLinks { my $FileName = shift; my @wordList = bustFile($FileName); } sub bustFile { my $FileName = shift; open(IN, "$FileName") || die "Cannot open $FileName: $!\n"; my @text = do {local $/; }; @pieces = split_text(@text); @pieces = check_links(@pieces); return @pieces; } sub split_text { $_[0] =~ /("[^"]*"|[^\s"]+)/g; $_[0] =~ s/\.$//g; $_[0] =~ s/^\.//g; $_[0] =~ s/\s$//g; $_[0] =~ s/^\s//g; } sub check_links { my @pieces = @_; my @list; open(WORDLIST,"/www/htdocs/data/linklist.txt") || die "Cannot open /www/htdocs/data/linklist.txt: $!\n"; foreach my $word (@pieces){ open(WORDLIST,"/www/htdocs/data/linklist.txt") || die "Cannot open /www/htdocs/data/linklist.txt: $!\n"; my ($checkLine, $checkWord, $checkLink); while ($checkLine = ) { ($checkWord, $checkLink) = split(/\t/, $checkLine); if ($word eq $checkWord) { $word = "$word";` } push @list, $word; last if ($checkWord gt $word); } close WORDLIST; } return @list; } 1;