Gentoo Archives: gentoo-dev

From: "Chad M. Huneycutt" <chad.huneycutt@×××.org>
To: gentoo-dev@××××××××××.org
Subject: [gentoo-dev] perl question
Date: Fri, 03 Aug 2001 22:34:26
Message-Id: 3B6B7A60.4040109@acm.org
1 Can anyone explain to me why this I can't see $dir inside the unless
2 block in the code fragment below?
3
4 sub recurse {
5 my $dir = shift;
6
7 print "dir: $dir\n";
8 unless ( defined($exceptions{$dir}) ) {
9 print "$dir is not an exception
10 }
11 }
12
13 basically, dir is correct in the first print statement, and then gone
14 inside the unless block (even if I do a "unless (0)", the second print
15 shows $dir as undefined).
16
17 I basically want to make sure that the problem is not that I am unaware
18 of some scoping rule of perl. I believe that this code is just acting
19 unexpectedly, but I want to make sure before I spend any more time
20 debugging it. And yes, this is a gentoo-related program.
21
22 Thanks,
23 Chad