in reply to Creating Variables Just to Pass into Subroutine?

Since your job is to refactor, i recommend using named parameters with defaults:

sub ampNotify { my %args = @_; # set defaults $args{severity} = defined $args{severity} ? $args{severity} : 3; $args{othercontact} ||= 'None'; .... }

And then you can call like so:

ampNotify( message => join( "\n", "Server: $server", "File: $origfile", "Erro +r: foo" ), subject => "Error processing $filename", who => 'su_and_it', path => $work_dir, file => $missingdeptfilename, );

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Creating Variables Just to Pass into Subroutine?
by mdskrzypczyk (Novice) on Jul 22, 2015 at 13:42 UTC
    While I do agree that the calling of the function gets cleaned up a lot, I fear that it adds complexity to the function definition that the team in my department may have trouble understanding further down the road. I know I said I need to refactor but I'm also trying to make the code a little more intuitive for the people that don't really get perl that much, is there a way to consolidate the two?