You want a regular expression (regex or regexp). They can be very in depth, but they're easy once you get the hang of them. You want something like this:
if(open(FILE,"myfile.txt")) {
while(<FILE>) {
if(/^IDX/) {
#Code here-- your line is in the $_ variable, complete with newline...