i have taken a input file by using @ARGV[0],then icounted the number of lines in the file,using the split function i splited the sentence and pushed it in an array.and counted how many times the word is repeated.similarly,this is for single word,similarly i have paired two words from the array,and now i want to count the number of occurence of this,please help me out of this..........the code is here.
Expand|Select|Wrap|Line Numbers
- #!/user/bin/perl
- $file=@ARGV[0];
- undef $/;
- open (FH,"$file");
- @f=<FH>;
- $n=<FH>;
- close (FH);
- print "$n\n";
- $a=@f;
- print "the number of lines in the file is:$a\n";
- foreach $lin(@f)
- {
- chomp($lin);
- push(@b,split (/\s+/,$lin));
- }
- print "@b \n";
- $c=@b;
- print "total numbers is $c\n";
- for $i(0 .. $#b-1)
- {
- $bigram=($b[$i] . " " . $b[$i+1]);
- print "$bigram\n";
- }
it that how many times it appers in pair.
Expand|Select|Wrap|Line Numbers
- $count=0;
- while($n =~ /this is/)
- {
- $count += "$n";
- $count++;
- }
- print "to play=$count\n";