sub func { for (my $s = @_ ? $_[0] : $_) { ... do something with $_ ... return $_; } } $new = func($old); @new = map func, @old;