glob - Perl File Globbing Oddities -
i'm writing script loop through range of numbers, build glob pattern, , test if file exists in directory based on glob.
the images nascar car number images, , follow the following pattern:
1_earnhardtganassi_256.tga 2_penskeracing_256.tga
here snippet of script using:
foreach $currcarnum (0..101) { if (glob("//headshot01/cars/${currcarnum}_*_256.tga")) { print("car image $currcarnum exists\n"); } else { print("car image $currcarnum doesn't exist\n"); } }
the problem i'm having, images exist in directory, , should match file glob pattern not.
for example, file following name returns not existing:
2_penskeracing_256.tga
whereas, following returns existing:
1_earnhardtganassi_256.tga
if use same file glob pattern in dos or cygwin, both files listed properly.
are file glob patterns interpreted differently in perl? there missing?
you need have results returned in list format instead of scalar format. try if statement, worked me when tested it.
if (my @arr = glob("//headshot01/cars/${currcarnum}_*_256.tga")) {
Comments
Post a Comment