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]>
Well, I went back to my Learning Perl book and was reminded of the glob
operator.  Here is the code I came up with.

my @opt_files = glob "*";

foreach $_ (@opt_files) {
	if ($_ =~ /myfilename.ext/i) {
		open FH, $_;
		@lines = <FH>;
		# do stuff on $lines
		close FH;
	}
}

It seems to work.  I just needed to get my head around this again.  My
hangup was trying to ignore the case while reading the glob from the
filesystem and I wasn't finding the answer.

Thanks for readin'!

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