* scalars as themselves * each array as an array reference (a reference is a scalar) * each hash as a hash reference (a reference is a scalar) #### 1. there is no reason to pass a reference to $template(a scalar) to the subroutine - why not just pass $template? Forget about the reference - then in the subroutine you can do my ($output, $input) = @_; and just use $output in the subroutine, instead of having to use $$output. 2. when you pass \@temp_fyle in the call to subroutine file_expansion, that's fine. This is just my preference, but IMHO it helps keep your code simpler and more understandable if you name variables consistent with what they contain. For example, in subroutine file_expansion, name the imcoming parameter that is a reference to the array what it is - a reference, like this: my ($output, $input_arrayref) = @_; or maybe even better my ($output, $temp_fyle_arrayref) = @_; Then, since you can actually use the reference to point at array elements (instead of having to dereference the array reference into an array), you can do something like this print "first element is $temp_fyle_arrayref->[0]\n"; to refer to the 1st element of the array, instead of having to do my @new_array = @$temp_fyle_arrayref; my $first = @new_array[0]; print "first element is $first\n"; which takes more memory since you are creating another array(@new_array).