try { my block of code here} catch {the exact error here} #### open (FOO, '/var/log/messages') or [die||warn||carp] "There was a problem: $!\n";