<SomeStuff> equivalent to glob "SomeStuff" (except for all the ambiguities with <> , which are also used to read from file descriptors - see perldoc perlop and find I/O Operators there). Therefore, your examples are not equivalent. You have to use
my @files = glob "\"rawdata/*_${term}_*.csv\"";
instead.
However, why space in the template matters: perldoc -f glob tells a story. Regular glob (and therefore <> , which is implemented via glob ), treats spaces as a pattern delimiter. The documentation also mentions File::Glob and its bsd_glob function, which does not treat spaces as pattern delimiters. So think about it:
use File::Glob ':glob'; my $term1 = "some stuff"; my @files1 = glob "dir/${term1}*"; my $term2 = "more"; my @files2 = glob "dir/${term2}*"; print join(' :: ', sort @files1), "\n", join(' :: ', sort @files2), "\n";
Possible output with some files that I just created:
[0 mosu@tionne ~/tmp] ~/test/test1.pl dir/some stuff is betther than other stuff.doc :: dir/some stuffy teachers.txt dir/more beer.txt :: dir/more_is_less.csv
source share