Re: Case insensitive file open in Perl

Nate Bargmann <n0nb-/[email protected]>
Newsgroups gmane.org.user-groups.aclug.discussion
Organization Amateur Radio!
Message-ID <[email protected]>
* Bruce Bales <[email protected]> [2009 Nov 02 20:09 -0600]:
> On Monday 02 November 2009 19:50:00 Nate Bargmann wrote:
> > Maybe I'm just braindead tonight (likely as it seems as though I've not
> > adjusted to the time change yet).
> >
> > I'm working on a program that will load a user supplied file.  Since
> > the file will be downloaded from the Web, it's possible that it will be
> > all upper case, all lower, or a mixture.  Nice, huh?
> >
> > I'm trying to recall how one goes about doing a case insensitive search
> > for the filename.  I know that I can use the //i matching operator.
> > Would a foreach loop and passing each glob by the /filename.ext/i match
> > be the way to go?
> >
> > Thanks!
> >
> > - Nate >>
> 
> How about "locate -i filename" ?

It only works on the database created by the locatedb command and is
only current to the time `locatedb' has been run.  Not only that but it
shows every occurance of the string in the filesystem.  In my case I'm
only interested in the current directory, i.e. where the program was
invoked from.

> cat filename | tr "[:upper:]" "[:lower:]" will make the whole file lower case.

Unless I'm missing something, passing the resulting variable will cause
open() to fail as the filename in the directory will still be of
indeterminant case.

Thanks for the reply, Bruce.

- Nate >>

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Ham radio, Linux, bikes, and more: http://n0nb.us/index.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.