If I write the script the following way:U:/TEMP/TEMP/A/Test01.txt U:/TEMP/TEMP/C/Test03.txt U:/TEMP/TEMP/B/Test02.txt
then it prints as shown:#!/usr/bin/perl use strict; use warnings; my %address = ( A => qq{U:/TEMP/TEMP/A}, B => qq{U:/TEMP/TEMP/B}, C => qq{U:/TEMP/TEMP/C}, ); for my $t (keys %address) { print "$t : $address{$t} : ", glob ("$address{$t}/Test*"), "\n"; }
If I write it in the form:A : U:/TEMP/TEMP/A : U:/TEMP/TEMP/A/Test01.txt C : U:/TEMP/TEMP/C : U:/TEMP/TEMP/C/Test03.txt B : U:/TEMP/TEMP/B : U:/TEMP/TEMP/B/Test02.txt
then the output is as follows:#!/usr/bin/perl use strict; use warnings; my %address = ( A => qq{U:/TEMP/TEMP/A}, B => qq{U:/TEMP/TEMP/B}, C => qq{U:/TEMP/TEMP/C}, ); for my $t (keys %address) { my $file = glob ("$address{$t}/Test*"); print "$t : $address{$t} : $file, \n"; }
Why it behaves itself different?A : U:/TEMP/TEMP/A : U:/TEMP/TEMP/A/Test01.txt, Use of uninitialized value $file in concatenation (.) or string at ... + line 15. C : U:/TEMP/TEMP/C : , B : U:/TEMP/TEMP/B : U:/TEMP/TEMP/B/Test02.txt,
In reply to glob behavior by vagabonding electron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |