use strict; use warnings; open my $textfile, '<', 'C:\Users\msmolik\Desktop\PERL test stuff\testfile.log' or die $!; while ( my $dtmf = <$textfile>) { if ( $dtmf =~ m/ccParty<(.+)>.+DTMF<(\*\d)>/ ) { print "$dtmf\n"; } } { close $textfile; }