#!/usr/bin/env perl use strict; use warnings; sub _validate_arguments { my ( $first_arg, $second_arg ) = @_; croak "Called without arguments." if @_ < 1; croak "Called with " . scalar @_ . " arguments. Expected arguments: 1 or 2." if @_ > 2; croak "The first argument is not defined." if ! defined $first_arg; ... ... carp "The first argument refers to an empty list!" if ! @$first_arg; return $first_arg, $second_arg; } sub my_function { my ( $first_arg, $second_arg ) = _validate_arguments( @_ ); return if ! @$first_arg; ... ... }