Skip to content

Instantly share code, notes, and snippets.

@prakashk
Last active December 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prakashk/7680888 to your computer and use it in GitHub Desktop.
Save prakashk/7680888 to your computer and use it in GitHub Desktop.
Print file names matching the given argument (exactly, no wild-cards) while ignoring case
#!/usr/bin/env perl
## look for files in case-insensitive manner
use strict;
use warnings;
use feature 'say';
use File::Glob ":glob";
my $filename = shift or die "Missing filename";
sub nocase_file_matches {
my $name = shift;
my $lc_name = lc $name;
grep {lc eq $lc_name} bsd_glob("$lc_name*", GLOB_NOCASE);
}
say for nocase_file_matches($filename);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment