in reply to Recursive string building: stepwise and final strings differ

Man you boorked the html bad princpawn. =P Your problem relates to $incr which you local $incr;. Thus the code that is called to an outside sub sees the "outer" $incr thanks to the our.

I'd think about changing that code to either my $incr; or keeping a stack of @incr and using $incr[++$depth]=0; and $incr[$depth] whereever you have been using just $incr.

Does that make sense?

--
$you = new YOU;
honk() if $you->love(perl)

Replies are listed 'Best First'.
Re: Re: Recursive string building: stepwise and final strings differ
by princepawn (Parson) on Feb 12, 2001 at 22:25 UTC
    I got rid of the our and changed the local to my. But the code still outputs the same results. The problem with your explanation is that there is no access of $incr outside of the sub proc_array And if you check comp.lang.perl.moderated, you will see that I have an equivalent formulation of the problem there done without local() and instead keeping a stack. It's just a very hard thing to figure out.
      Ok, next attempt, take the ++ out of this line,
      my $bullet = sprintf "%s%s. %s\n%s", tab, ++$incr, $key, $self->proc_array(@$val);
      and see if it was causing the value of $incr to "pass thru".

      --
      $you = new YOU;
      honk() if $you->love(perl)