open(FF, "$fixmessageloc"); while(){ chomp($_); if($_ =~ /35=D/){ printf("Found $_\n"); } } Now this will return . Found 1 06/02/23 11:16:05:390 Inbound:, Outbound:, Bidirectional:*** 2 06/02/23 11:16:05:390 Received FIX message Message dump: 3 06/02/23 11:16:05:390 Resetting FIX session intraday. 4 06/02/23 11:16:05:406 Sent FIX Message Message dump: 5 06/02/23 11:16:35:109 Sent FIX Message Message dump: 6 06/02/23 11:16:37:234 Received FIX message Message dump: 7 06/02/23 11:16:37:234 Sent FIX Message Message dump: 8 06/02/23 11:16:37:265 Inbound:, Outbound:, Bidirectional:*** 9 06/02/23 11:16:44:671 Received FIX message Message dump: