use strict; use warnings; my @args = ( qw/fee fie foe fum/, undef, 1..3 ); print "No SFX\n", '-'x10, "\n"; Sub_With_NO_Side_Effects( @args ); print map { "'$_'\n" } @args; print "\nSFX\n", '-'x10, "\n"; Sub_With_Side_Effects( @args ); print map { "'$_'\n" } @args; sub Sub_With_NO_Side_Effects { &no_sfx_fix_undef; print "$_: '$_[$_]'\n" foreach 0..$#_; } sub Sub_With_Side_Effects { &fix_undef; print "$_: '$_[$_]'\n" foreach 0..$#_; } # This sub modifies the original calling function's variables. BAD NEWS sub fix_undef { defined $_ or $_ = '' foreach @_; } # This seems to be ok... sub no_sfx_fix_undef { @_ = map { defined $_ ? $_ : '' } @_; } __END__ # OUTPUT No SFX ---------- 0: 'fee' 1: 'fie' 2: 'foe' 3: 'fum' 4: '' 5: '1' 6: '2' 7: '3' Use of uninitialized value in concatenation (.) or string at C:\temp\test.pl line 9. 'fee' 'fie' 'foe' 'fum' '' '1' '2' '3' SFX ---------- 0: 'fee' 1: 'fie' 2: 'foe' 3: 'fum' 4: '' 5: '1' 6: '2' 7: '3' 'fee' 'fie' 'foe' 'fum' '' '1' '2' '3'