in reply to Re: Finding if files exist when names randomly have letters in both upper and lower cases
in thread Finding if files exist when names randomly have letters in both upper and lower cases

On second thought, this should work as well...

use File::Glob qw(:globally :nocase); # instead of if(-f $file) { if(<$file>) {

We're not surrounded, we're in a target-rich environment!
  • Comment on Re^2: Finding if files exist when names randomly have letters in both upper and lower cases
  • Download Code

Replies are listed 'Best First'.
Re^3: Finding if files exist when names randomly have letters in both upper and lower cases
by merlyn (Sage) on Jun 22, 2005 at 16:35 UTC
    use File::Glob qw(:globally :nocase); if(<$file>) {
    Thou Shalt Not Use Scalar Glob Unless Thou Understandest Thy Problems Perfectly.

    In layman's terms, your test will work "every other time" mysteriously.

    In real terms, what's happening is that a scalar glob context is established on the first hit, and then reused on the second hit, so you'll get your filename, then undef, then your filename, then undef, then your filename. Ick.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.


    update: And it was also pointed out to me in the CB that this is a readline() call, not a glob() call, which really wouldn't have worked.