use strict; use warnings; sub try (&;@) {}; sub catch (&;@){}; sub _ (&;@) {}; sub error_classes { return map { $_ => bless {}, $_ } @_; } use constant { error_classes qw( FileNotFoundError IsADirectoryError ) }; try { # your code here } catch { FileNotFoundError } sub { # handle exception }, # extra comma needed catch { IsADirectoryError } sub { # handle exception }, catch { # all other types of exceptions }; warn ('Should reach here'); try { # your code here } catch { FileNotFoundError }_{ # handle exception } catch { IsADirectoryError }_{ # handle exception } catch { # all other types of exceptions }; warn('Should reach here')