my $cvs_match = qr/whatever/; for (keys %INC) { push @versions, ($foo = `perldoc -m $_`) =~ /$cvs_match/; }