Last active
December 29, 2015 13:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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