open file while reading file line by line in @data, save lines from /^G/ (inclusive) to next /^G/ (exclusive) call parse_check on @data close file in parse_check, $data[0] =~ /^G/ or early return @find = split $data[0] on ":" remove /^G/ from $find[0] @field = parsed CSV output of @data[1,$#data]. remove /^E/ from @field for space in @field match space with each of @find if all succeed, well, you succeeded and return true outside of loop, return false