in reply to Can't use an undefined value as a symbol reference

Following in the footsteps of the Right Rev. JavaFan, line 4 won't compile either. Your @fils appears out of the blue and the opening { doesn't have a matching }.

Line 5 doesn't create any problems unless (the indenting suggests otherwise, but...) you don't mean to have the if clause run thru # do  something and on until line 12, but who knows whether do  something is the source of your problem...

Maybe line 4 compiles in your actual script, but not here.

So how are we supposed to help when you have obfuscated the problem.

Please, post a snippet (where snippet <= 20 lines) that actually compiles but still illustrates your difficulty.

And, oh yes, please add use warnings to your scipt. It may or may not help you here, but it surely will alert you to numerous mistakes as you write more code.