Quote:
Originally Posted by grail
What have you tried?
|
-----------------------------
#!/usr/bin/perl -w
my $count=0;
my $path="/home/perl/field.txt";
open(IN, $path)|| die "INVALID PATH\n";
print "\nEnter word\n";
$word=<stdin>;
chomp($word);
while(<IN>)
{
my @field=split(',',$_);
if ("$_" =~ /$word/)
{
$count++;
}
}
print"\n'$word' appeared :$count times\n\n";
close(IN)
This is what i tried , but the count is not accurate