1 |
"Chad M. Huneycutt" <chad.huneycutt@×××.org> writes: |
2 |
|
3 |
> Can anyone explain to me why this I can't see $dir inside the unless |
4 |
> block in the code fragment below? |
5 |
> |
6 |
> sub recurse { |
7 |
> my $dir = shift; |
8 |
> |
9 |
> print "dir: $dir\n"; |
10 |
> unless ( defined($exceptions{$dir}) ) { |
11 |
> print "$dir is not an exception |
12 |
> } |
13 |
> } |
14 |
|
15 |
I expect you've left out a " on the second print statement? :) |
16 |
|
17 |
> basically, dir is correct in the first print statement, and then |
18 |
> gone inside the unless block (even if I do a "unless (0)", the |
19 |
> second print shows $dir as undefined). |
20 |
|
21 |
it shouldn't. unless you've tied %exception into something that |
22 |
resets the keys on read. |
23 |
|
24 |
$ perl -le '$foo="foo"; print $foo; unless( 0 ) { print $foo }' |
25 |
foo |
26 |
foo |
27 |
|
28 |
-- |
29 |
Terje |