Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: case insensitive filename matching

by cog (Parson)
on Feb 10, 2005 at 12:35 UTC ( #429689=note: print w/replies, xml ) Need Help??


in reply to case insensitive filename matching

Get the list of all files in the filesystem, get the list of the files you want, and use grep:

grep { is_in(@mylist) } @files_in_the_filesystem

That'll give you the list of files you want (hopefully).

Of course, you'll have to code the is_in subroutine, which will probably contain a bit of code like this:

$newfile =~ /^$oldfile$/i

I hope that sets you in the right direction. Honk if you need more help :-)

Replies are listed 'Best First'.
Re^2: case insensitive filename matching
by edan (Curate) on Feb 10, 2005 at 13:37 UTC

    $newfile =~ /^$oldfile$/i

    As much as I like regexps, I would be much more likely to write that as:

    if ( lc $newfile eq lc $oldfile )

    In my eyes, that's the canonical case-insensitive equality comparision.

    --
    edan

      Yes, you're right :-)

      (what was I thinking? :-) )

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://429689]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2018-06-25 15:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (127 votes). Check out past polls.

    Notices?