in reply to Trouble Getting Local Variable $_ to return reformatted string

The short answer: you're modifying a copy of $_, so the caller doesn't see the modification. You should probably return the value, something like this:
# Note we assign the return value of the sub to $txt $txt = escape_html_character($txt); sub escape_html_characters { my $string = shift; $string =~ s/...some chars here.../...some escape.../g; # Note we return the modified string return $string; }
The key points here are that the modified string is returned from the subroutine and you assign the return value of the subroutine back into the $txt variable.

The long answer:

Have fun.