FIRST Level Description EQT.FIRST.Id: 2 EQT.FIRST.eqtID_01.allowedType: 4TEST EQT.FIRST.eqtID_02.allowedType: 5TEST SECOND Level Description #### my $data_file = "test.txt"; open(FILE, "< $data_file"); while() { if ( /FIRST Level Description/.. /SECOND Level Description/ ) { if (/EQT.FIRST.eqtID_(\d+).allowedType:([A-Z0-9]+)/) { ($str1,$str2 ) = ($1,$2); } print "$str1 \n $str2"; }}