sub do_something { my $args = shift; my $result = 0; # or "", or undef, or whatever my @errors = (); # Validate staff push @errors, "Where's the email?" unless ($args->{email}); push @errors, "Bad email" unless ($args->{email} =~ /\@/); # ... unless (@errors) { # Do something here # ... } return $result, @errors; } #### sub display_status { my @errors = @_; if (@errors) { print "Operation failed due to following errors:\n"; foreach my $error (@errors) { print "\t- $error\n"; } } else { print "Operation succeded\n"; } } #### my ($result,@errors) = do_something(\%args); if (@errors) { display_status(@errors); }