in reply to Eval and Exiting
Other people has pointed out the source of your script problem. I am just adding an observation: have you included the clause use strict; at the beginning of your script? It's very easy to get the scoping of the variables wrong otherwise.