in reply to File::Glob infinite loop with while loop unlike core glob function

I get no infinite loop when I change the "while" to a "for" loop, if that is a viable trade-off for you:
{ use File::Glob ':glob'; print "======with File::Glob ':glob'======\n"; for (glob "$folder/*.txt") { print "$_\n"; } print "Press <Enter>"; <>; }
  • Comment on Re: File::Glob infinite loop with while loop unlike core glob function
  • Download Code

Replies are listed 'Best First'.
Re^2: File::Glob infinite loop with while loop unlike core glob function
by Gulliver (Monk) on Jul 29, 2011 at 17:44 UTC

    Yes that does what I need, thanks.

    I only noticed this because I was working through the Camel book 'Filename Globbing Operator' section in Chapter 2 where it talks about while magic but the example didn't work for me because I was using File::Glob.