sub exec{ #... &log_action('error',$error); } sub log_action{ my $i = shift; #get first parameter my $error = shift; get second parameter # note that this $error here is not the same variable but has the same value! #do whatever with it... }