I'm trying to loop over some files in my directory in Perl. Let's say my current directory contains: song0.txt, song1.txt, song2.txt, song3.txt, song4.txt.
I supply "song?.txt" as an argument to my program.
When I do:
foreach $file (glob "$ARGV[0]") { printf "$file\n"; } It stops after printing "song0.txt".
However, if I replace "$ARGV[0]" with "song?.txt", it prints out all 5 of them as expected. Why doesn't Perl glob work with variables and what can I do to fix this?
perl script.pl "song?.txt".