in reply to Is there an array for $1,$2,$3... or some alternative ?

chomp(my $input = <STDIN>); my @simMatches = qw(abcd wxyz); my $pat = qr/(.)..(.)/; @simMatches = map{ @_ = /$pat/; s/$pat/$_[$input-1]/; $_ }@simMatches; print join $", @simMatches; __END__ $input == 1; a w $input == 2; d z