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.