I would suggest you throw an exception when an error occurs. You don't need if blocks if you do it with objects. Then you wrap this in a try-catch block, see module TryCatch
Basically you "try" your code, you "throw" an exception object when you have an error and you "catch" the error for displaying it elegantly. You catch block should be able to process any kind of exception. You code would be more generic like that.
You can build your own exception classes but I suggest you take a look on CPAN, there is plenty of exception modules.
There are no stupid questions, but there are a lot of inquisitive idiots.