http://www.perlmonks.org?node_id=917494

Gulliver has asked for the wisdom of the Perl Monks concerning the following question:

The core glob won't handle the foldername with spaces so I used the File::Glob version but it goes into an infinite loop printing the last file in the directory. How can I use bsd style glob with a while loop like I'm used to?

use warnings; use strict; my $folder = "/usr/fldr wth spaces"; print "====== core glob ======\n"; while (glob "$folder/*.txt") { print "$_\n"; } print "Press <Enter>"; <>; { use File::Glob ':glob'; print "======with File::Glob ':glob'======\n"; while (glob "$folder/*.txt") { print "$_\n"; } print "Press <Enter>"; <>; }