in reply to Can't call method "value" on an undefined value at X??
I agree with the (rather cryptic) advice to use eval, which is the Perl way of trapping an exception. I would say, rather categorically, that you always want to write for the general case; for the way it works 99% of the time. Don’t write if statements to check for what almost never happens. Just be certain that an exception will, in fact, be thrown ... and then, catch it.