Gentoo Archives: gentoo-dev

From: Terje Kvernes <terjekv@××××××××.no>
To: gentoo-dev@××××××××××.org
Subject: Re: [gentoo-dev] perl question
Date: Sat, 04 Aug 2001 07:31:48
Message-Id: wxx8zh0ossi.fsf@sex.ifi.uio.no
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

Replies

Subject Author
Re: [gentoo-dev] perl question "Chad M. Huneycutt" <chad.huneycutt@×××.org>