vagabonding electron has asked for the wisdom of the Perl Monks concerning the following question:
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,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: glob behavior
by davido (Cardinal) on Mar 20, 2012 at 08:14 UTC | |
by rovf (Priest) on Mar 20, 2012 at 08:34 UTC | |
by vagabonding electron (Curate) on Mar 20, 2012 at 08:56 UTC | |
by vagabonding electron (Curate) on Mar 20, 2012 at 09:34 UTC | |
|
Re: glob behavior
by Anonymous Monk on Mar 20, 2012 at 08:45 UTC | |
by vagabonding electron (Curate) on Mar 20, 2012 at 09:01 UTC | |
by vagabonding electron (Curate) on Mar 20, 2012 at 15:45 UTC | |
by davido (Cardinal) on Mar 20, 2012 at 19:23 UTC | |
by vagabonding electron (Curate) on Mar 23, 2012 at 15:38 UTC |