$Fil = "test.txt" open Fil or die "cannot open file" while() { if($_=~m/name_of_the_struct/ .. $_=~m/};/) { if($_=~m/[ ]*{[ -,"\nA-Za-z0-9]*}/ { do_some_oper; } } } Example struct struct name_of_the_struct[]= { { 1, "abc", 234 , 567,90 }, {2,"asd",333,455,677} };