develooper Front page | perl.perl5.porters | Postings from August 2001

RE: [PATCH List::Util] fix stack/scoping problems

Thread Previous
Wilson, Doug
August 21, 2001 15:59
RE: [PATCH List::Util] fix stack/scoping problems
Message ID:

> From: Robin Houston []

> The patch below is an attempt to fix the problem reported by 
> Doug Wilson.
> It seems to work, but I'd appreciate it if someone (Graham?) 
> could make
> sure I haven't done anything too hideous.

Getting close :) but the following still fails no matter where
I put the PUSH & POP BLOCK. If I uncomment everything below, all the
values echoed by warn() appear to be correct, but the value that
finally makes it to '$sum' is null. However, if I put a
right before the POPBLOCK (with the POPBLOCK after the loop),
then it works ok. Someone let me know if this is the right thing to do...

sub add {
    #warn "0:$_[0] 1:$_[1]";
    $_[0] + $_[1];

my @list = ([3,0],[2,0],[1,0]);
my $sum = reduce {
                   #warn "a1: $$a[0] b1: $$b[0]";
                   #my $tmp =
                   [ 0+add($$a[0], $$b[0]), 0 ];
                   #warn "a2: $$a[0] b2: $$b[0] tmp: $$tmp[0]";
                 } @list;

warn "sum: $$sum[0]";
print "not " unless $$sum[0] == 6;
print "ok 6\n";

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About