in reply to How can I run only a determined part of script not using if/then statements

In addition to grep's answer:

Adding use warnings; to your code will give you warnings upon errors like this.

Additionally: using filenames entered by users is probably not a good idea. What if the filename is '../../*' and $func is 'rm'?

Do yourself a favour and read a bit about taint.

Also consider using strict and error messages that give you more information than just that something failed.