in reply to (jcwren) RE: modify variable on pass by value
in thread modify variable on pass by value

Actually scalars or arrays as inputs is handled if you can handle an array as input. What you wanted to do is properly handle scalars and arrays as desired output. (Which your function does.)

That said I will admit to occasionally using the following hack that assumes that if you want a scalar back, you will always give me exactly one value. (I know, still I do it from time to time.)

sub remove_caps; if (1 != @_) { return map {remove_caps($_)} @_; } my $str = shift; $str =~ tr/A-Z//d; return $str; }