in reply to Parse for a name after a keyword search in all the files, given directory as input

G'day prash_sri,

Welcome to the Monastery.

I see you've received copious, excellent advice on things to fix.

When you've fixed all those issues, and finally want to open a specific file, remember that the file is in $dir, which is not necessarily the current directory: open "$dir/$file", not $file.

When dealing with a single item, use the singular form, as I did in the previous paragraph: use $file not $files (which looks like an arrayref to me, e.g. my $files = \@files;).

Also, you might find the autodie pragma useful.

— Ken

  • Comment on Re: Parse for a name after a keyword search in all the files, given directory as input
  • Select or Download Code