Just assign to local variable:
@a = qw(foo bar baz);map {my $ch = $_; scalar grep $_ =~ /^$ch/, @a} qw(a b c d e f)