in reply to To get file names from the search string

For example with a combination of readdir and grep:

my $dirname= '/some/directory/with/files'; my $input= '2013-09-04'; opendir my $dh, $dirname or die "Couldn't read '$dirname': $!"; my @found= grep /^\Q$input\E/, readdir $dh; ...

In my opinion the easiest way is to use File::Glob::bsd_glob:

use File::Glob qw( bsd_glob ); my @found= bsd_glob("$input*");

Replies are listed 'Best First'.
Re^2: To get file names from the search string
by RichardK (Parson) on Sep 05, 2013 at 14:30 UTC

    That's not what grep -il is doing, it outputs the filenames of the files whose content contains the string. So IMHO it's easier to use grep, unless there's more to this problem that we know about.