sub test { for (my $i = 0; $i < @_; $i += 2) { if ($_[$i] eq 'a') { $_[$i+1] = 'found a'; } } } my $a = 'not found'; test b => 3, a => $a; print "$a\n";