in reply to Access given folder to parse a file
this simply will take your first arg and read the specified directories contents into the array "@dir". then it will take the second argument "$file" and chomp it so there is no trailing unwanted characters or spaces.use File::Slurp; my @dir = read_dir($ARGV[0]); my $file = $ARGV[1]; if ($file ~~ @dir){ print uc"$file FOUND"; } else{ print uc"$file not found"; } #usage - script_name.pl [directory] [file_name] #eg. - script_name.pl [folder(1)] [my_log_file.log]
|
|---|