in reply to Modifying a parameter to a recursive function

I'm not sure what proof you have that your strings are reverting. Be aware that both @contents and $s are the results of calling a method on an object. If you are expecting a substitution on a string returned by contents_list to be refs, then then you really want content_refs_list instead. The HTML::Entity method contents_list only returns a list, not a list of refs. It seems you're changing something other than what you want.

As for being able to change your arguments in Perl, take a look at this simple test case:

my @foo = qw( aaaaaaaa bbbbbbbb cccccccc dddddddd eeeeeeee ffffffff); sub foo { for ( @_ ) { $_ =~ s/(.)\1/$1/ || return; print $_ . "\n"; foo( $_ ); } } foo @foo; print @foo;

The above produces this:

aaaaaaa aaaaaa aaaaa aaaa aaa aa a bbbbbbb bbbbbb bbbbb bbbb bbb bb b ccccccc cccccc ccccc cccc ccc cc c ddddddd dddddd ddddd dddd ddd dd d eeeeeee eeeeee eeeee eeee eee ee e fffffff ffffff fffff ffff fff ff f abcdef