#!/usr/local/bin/perlprint ("Word to search for $ARGV[0]\n");$filecount = 1;$totalwordcount = 0;
while ($filecount <= @ARGV-1) {unless (open (INFILE, $ARGV[$filecount])){die ("Can't open input file $ARGV[$filecount]\n"); } $wordcount = 0; while ($line = ) { chop ($line); print ("Before split : $line\n"); @words = split(/ /, $line); print ("Content is : @words\n"); $w = 1; while ($w <= @words) { if ($words[$w-1] eq $ARGV[0]) { $wordcount += 1; } $w++; } } }
print ("total number of occurrences $totalwordcount\n");
No comments:
Post a Comment