As I said earlier, there is some directory called verilog which is HDL language used for hardware description. Inside this directory there are many sub-directories and .v files are available. So I need to search for a pattern called clk in all the files and the directory with the line number exactly where is the pattern located in each file and i need the count how many times clk has appeared. Now i could able to go through the directories and files but I could not get the line number of the file where the pattern has occured and the count(how many times the pattern has repeated) this is what I am looking for.Can you Plz help me on this?
#!usr/bin/perl -w
#use strict;
#use FindBin;
#use lib File::Spec->catdir($FindBin::Bin,'Lib');
#use ExtUtils::Installed;
use File::Find;
use File::Slurp;
my $in_dir="/home/prodigydell3/verilog";
my @all_files;
my $pattern='test>clk(\n|\t|\s)</test';
find(sub {
push @all_files,$File::Find::name if(-f $File::Find::name);
},$in_dir);
my $count=0;
foreach my $file_(@all_files){
my @file_con=read_file($file_);
foreach my $con(@file_con){
my $match = "true" if ($con=~m/$pattern/igs);
$count++;
}
print "The pattern is found in $file_ and number of lines is $count \n";
}