local $/ = undef; open(FH,"<","test.txt") or die "Could not open the file due to $!"; my $fcontent = ; close FH; foreach (@typedefs) { if ($fcontent =~ /$_/){ # perform various actions here if line match } }