Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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?
marto should develop the 'anti-social network'
[marto]: sign up to make it impossible to be contacted online :P
[Discipulus]: karl: configuring the network is like: nmcli conn add con-name "name name" ifname eth0 type eterneth.... not so different from powersehell longness

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2017-12-14 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (389 votes). Check out past polls.

    Notices?