my code is as follows but somehow it doesn't seem to count the number of occurences in the second file.
Expand|Select|Wrap|Line Numbers
- #!/usr/bin/perl -w
- $datafile = $ARGV[0];
- print "$datafile\n";
- open (LIST1, $datafile) || die "File not found\n";
- $tags = "tags.txt";
- open FILE, "$tags" or die "Couldn't open file: $!";
- @test=<FILE>;
- $string = join("", @test);
- while(<LIST1>) {
- chomp;
- my(@v) = split(/\t/);
- #$count = ($string =~ tr/$v[0]//);
- $count = split(/$v[0]/, $string);
- print "$v[0]\t$count\n";
- }
- close FILE;
- close LIST1;
split also doesn't give the numbers correctly. Anything I am missing?
Thanks.