in reply to Messing with @_

Messing with @_ would make me nervous too. I would definitely stick with the Sub_With_NO_Side_Effects().

On the other hand, I'm against using subs when not needed. While checking for definedness annoys me too, it's often done while assigning @_ to local variables in the sub, so it's not that much more trouble. At least not worth the bother of another sub call when a cut and paste will do.
sub Sub_With_NO_Side_Effects { my @arg = map { defined $_ ? $_ : '' } @_; print "$_: '$arg[$_]'\n" foreach 0..$#arg; }

Replies are listed 'Best First'.
Re^2: Messing with @_
by TGI (Parson) on May 30, 2008 at 16:39 UTC

    That's exactly what I was doing, and then unpacking @arg--over and over again. When I do something over and over again, I usually reach for a sub.

    Where you draw the line between repeating code and writing subroutines is a matter of style. I tend to reach for a sub on the third instance. YMMV.


    TGI says moo