Combining the IDs into one regex and then just reading line by line and matching the combined ID regex against the start of each string.
use Modern::Perl qw/2015/;
my @regex = <DATA>;
chomp @regex;
my $regex = join '|', @regex;
$regex = qr/$regex/;
open( my $FH, '<', 'data.txt' ) or die "Could not open file: $!";
while ( my $line = <$FH> ) {
print "Matched $1 at $line" if $line =~ m/^($regex)/;
}
__DATA__
GSAD1234
GSAD2345
GSAD4567
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
My blog:
Imperial Deltronics