Hello,
once again seeking for your help. I have a file 'param' with '$count $word' on each line and a file 'sent' with some text, each word on each line
------param-------
200 dog
300 cat
100 rat
400 hen
-----sent--------
The
cat
catches
the
hen
...
I need to tag each word in the 'sent' file with the corresponding count value from the 'param' file:
The
cat 300
catches
the
hen 400
...
And my code is:
#!/usr/bin/perl
use strict;
use utf8;
use warnings;
open PARAM, "param" or die $!;
open DEV, "sent" or die $!;
my %counts;
my @dev;
while(<DEV>){
chomp;
@dev = <DEV>;
}
while(<PARAM>) {
chomp;
my($count, $word) = split / /;
$counts{$word} = $count;
}
foreach my$word_dev(@dev){
if(exists $counts{$word_dev}){
print "$word_dev $counts{$word_dev}\n";
}
}
I believe there is some silly mistake over there, but I can't find it. I will very appreciate your help:)