{ local $/="__Data__"; open my $fh,"<","logA.txt" or die "Unable to open file"; while(<$fh>) { # remove the input record separator value of __Data__ chomp; # display the line of each record if(/([^\n]*)\n(.*)/sm) { print "$1\n"; } } close ($fh); }