in reply to Re: How can I write this in a "simpler" way?
in thread How can I write this in a "simpler" way?

Yeah, because technically we haven't reached the files yet, we are supposed to "feed" the input of the file with re-direction to the program, like:
cat MYFILE | program.pl

so, in that case, I guess what I wrote with defined is the correct way?