my $categories = eval { get_categories_by_mgr($prod_mgr_id); }; if($@) { # do something useful with $@ here }