in reply to Re: Scalar refs, aliasing, and recursion weirdness.
in thread Scalar refs, aliasing, and recursion weirdness.

and it worked.

Actually not--unless your results are different to mine?

It only retains the last change and I want to retain the accumulated changes.

P:\test>junk >> 'aaaaaaaaaa' >> 'aaaaaaaa' >> 'aaaaaa' >> 'aaaa' >> 'aa' >> '' << '' << ' ( aa ) ' << ' ( aaaa ) ' << ' ( aaaaaa ) ' << ' ( aaaaaaaa ) ' << ' ( aaaaaaaaaa ) ' ( aaaaaaaaaa )

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

Replies are listed 'Best First'.
Re^3: Scalar refs, aliasing, and recursion weirdness.
by ikegami (Patriarch) on Feb 04, 2005 at 22:57 UTC
    Maybe you want
    ${ $_[ 0 ] } = " ( $boo ) ";
    or

    if( length ${ $_[ 0 ] } > 2) { my ($pre, $mid, $post) = /^(.)(.*)(.)$/; recurse( $mid ); ${ $_[ 0 ] } = "$pre ( $mid ) $post"; }

    Just guessing, cause you didn't specify what output you want.

      I've updated the OP to clarify my expectations.

      The whole point is to modify the referent in-place. The selection for the substring reference used by the recursion is far more complicated in the real situation.

      The point of my question is not really "How to get this output", but more "Why do changes that get made during recursion get unwound, when the entity being modified is (relatively speaking) static."


      Examine what is said, not who speaks.
      Silence betokens consent.
      Love the truth but pardon error.