package search; use strict; use warnings; sub find($$){ if ($#_ != 1) # Check the number of arguments for the command. @ARGV is the default perl- { # Array that stores command line arguments return "Format Error:Usage- script.pl <'String'>\neg:search.pl config_file 'X YZ'\n"; exit -1; } my $file=$_[0]; # Stores the filename my $key=$_[1]; # Stores the key my $count = 0; # To increment if keyword is found if (-e "$file") # Checks if file is present else Return Error { open (DATA,$file); chomp($key); # Removes the new line character from the keyword while (defined (my $line = )) # Search until Handle is open { if ($line =~ /\b\Q$key\E\b/i) # Matches for the exact full keyword(Does'nt show if the key is a part of another word) { return "Passed\n"; $count++; exit 0;} # Increment count if keyword found } if($count == 0) # If count is Zero, no Keyword match was found { return "Failed\n" ; exit 1; } close (DATA); } else { return "Error: file does'nt exist\n"; exit -1; } } 1; # Must exit in true value