use strict; use warnings; use Data::Dump qw/pp/; sub ampNotify { my ($who ,$subject ,$severity ,$message , $othercontact ,$path ,$file) = @_; # --- this will use named parameters if first arg is hashref if (ref($who) eq "HASH"){ # - defaults (optional) my %defaults = ( who => "su_and_it", severity => 3, othercontact => "None", ); my %args = ( %defaults, %$who); # - parameter check (optional) my @obligatory = qw/subject message path file/; for (@obligatory){ die "missing '$_' argument in ampNotify() " unless exists $args{$_} } ($who ,$subject ,$severity ,$message , $othercontact ,$path ,$file) = @args{qw/who subject severity message othercontact path file/}; } # check content pp [($who ,$subject ,$severity ,$message , $othercontact ,$path ,$file)]; # --- your orig code following # ... } # --------- USAGE my $message= <<"__message__"; Server: SERVER File: ORIGFILE Error: Departments missing from WWMBR_NAMES.TXT __message__ ampNotify( { who => "su_and_it", severity => 3, othercontact => "None", path => 'FOO', file => 'BAR', subject => "Error processing 'BAZ' ", message => $message, } );