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]>
* Steven Saner <[email protected]> [2009 Nov 02 20:09 -0600]:
> 
> On Nov 2, 2009, at 7:50 PM, 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?
> 
> That would work. You could also use lc() or uc() to convert each
> filename to all lower or upper case and then do a simple eq
> conditional.

Until I invoke the open() function since mangling the filename changes
it from its case in the filesystem.  It seems as though not caring
about a filename's case is somewhat unusual, actually, I do care as I
want to verify the file exists and then open and read it in my Perl
program regardless of the case of its name.

- 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.