Do you have:
at the top of your script? If you don't, try putting it in. If something is going wrong (i.e. the line you're reading in is undef), it will tell you. Also, can you post more of the script? There are a lot of possibilities for what is going wrong. For instance, if you do not have an open ("FILE", "< ./file") or die("Can't open the file $!"); and are just using open ("FILE", "< ./file"); you would always get an undef (or maybe a "") if you read in the lines.
Want to support the EFF and FSF by buying cool stuff? Click here