in reply to Vector space algorithm
Hi
You can do the following the steps:
1. Glob the parent directory or use File:Find to find all the relevant files. 2. Read the files (which you are interested in) and parse out the words you want in an output file. 3. You will have the dictionary of words ( and locations of the files if you are interested in). Here is some start code
## Globbing opendir(DIR, $inPath) or die$!; my @xmlfiles = glob("*.xml"); foreach my $file (@files) { print "$file\n"; ## Lists all the files }
Reference: GlobFiles
for(my $file =0; $file<=$#xmlfiles; $file++){ ## $#xmlfiles gives you +the last index of the file or length of the array -1 open my $IN, $file or die $!; open my $OUT, ">outfile.txt" or die $!; while(<$IN>){ ## read the file line by line ## split and parse the words you are interested in ## suppose $word has the word u want to output in the file then, $word + is a scalar variable print $OUT $word,"\n"; } close($IN); } close($OUT);
Reference: split, openreadfiles, whileloop
|
|---|