# -----------------------------------------------------------------------------------------------------
# Program: to search a pattern recursively inside files for the given directories
#-----------------------------------------------------------------------------------------------------
# 1. First command line argument is treated as the pattern string
# 2. second argument is the directories to search and can be comma separated list.
# Full path to the search directories should be provided.
# 3. sample ways to run the script from command prompt.
# Perl filename.pl "pattern string" c:\directorry\dir;c:\dirl\dir2
# Perl filename.pl pattern_string "c:\dir3\dir;c:\dir1\dir2"
# Perl filename.pl mypattern
#-------------------------------------------------------------------------------------------------------
#use strict;
#use warnings;
use File::Find;
use cwd;
my $search_pattern; #="Program";
my $dir; #='c:\users\pocuments';
my $outputfile='search_results.txts';
my @directories;
my $length;
#save the results to this file
open ( my $fh, '>' , $outputfile) or die "could not open '$filename' $!";
if(S#ARGv == -1)
{
#print "No cmd args(S#ARGv) provided\n" ;
}
#if,only search pattern provided use current directory as input if (S#ARGv == 0)
#print "one cmd line arqs(S#ARGv)\n" ;
# Program: to search a pattern recursively inside files for the given directories
#-----------------------------------------------------------------------------------------------------
# 1. First command line argument is treated as the pattern string
# 2. second argument is the directories to search and can be comma separated list.
# Full path to the search directories should be provided.
# 3. sample ways to run the script from command prompt.
# Perl filename.pl "pattern string" c:\directorry\dir;c:\dirl\dir2
# Perl filename.pl pattern_string "c:\dir3\dir;c:\dir1\dir2"
# Perl filename.pl mypattern
#-------------------------------------------------------------------------------------------------------
#use strict;
#use warnings;
use File::Find;
use cwd;
my $search_pattern; #="Program";
my $dir; #='c:\users\pocuments';
my $outputfile='search_results.txts';
my @directories;
my $length;
#save the results to this file
open ( my $fh, '>' , $outputfile) or die "could not open '$filename' $!";
if(S#ARGv == -1)
{
#print "No cmd args(S#ARGv) provided\n" ;
}
#if,only search pattern provided use current directory as input if (S#ARGv == 0)
#print "one cmd line arqs(S#ARGv)\n" ;
No comments:
Post a Comment