in reply to substr on $_

If you assign the results of a substition regex, that doesn't assign the new string. Regex substitutions are done in-place. The return value is the number of substitutions, not the new string.

It sounds like you want to do too many operations on one line. You're not changed by the character, my friend! Just do your assignment, then your substitution.

my $new = $_; $new =~ s/foo/bar/g;

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.