in reply to Scalar refs, aliasing, and recursion weirdness.
I don't know why, but on a hunch, I tried this change:
#! perl -slw use strict; sub recurse { print ">> '${ $_[ 0 ] }'"; if( length ${ $_[ 0 ] } ) { #recurse( \ substr( ${ $_[ 0 ] }, 1, -1 ) ); #old recurse( \( my $boo = substr( ${ $_[ 0 ] }, 1, -1 ) ) ); #new ${ $_[ 0 ] } = " ( ${ $_[ 0 ] } ) "; } print "<< '${ $_[ 0 ] }'"; return; } my $str = 'aaaaaaaaaa'; recurse \$str; print $str;
and it worked. I leave it up to you to explain it (cause I'm going home!)
I'm don't think this is the output you want, because it would be a very convoluted way of getting it. But you didn't specify what you wanted.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scalar refs, aliasing, and recursion weirdness.
by BrowserUk (Patriarch) on Feb 04, 2005 at 22:54 UTC | |
by ikegami (Patriarch) on Feb 04, 2005 at 22:57 UTC | |
by BrowserUk (Patriarch) on Feb 04, 2005 at 23:23 UTC |