#!/usr/bin/perl -w

# Pass by reference
sub concatenate_dna {
	# In Pass by Reference, arguments are collected
        # from the @_ array, and saved as scalar variable.
	# This is because a reference is a special kind of 
	# scalar data value. 
	my($genes1_ref, $genes2_ref) = @_;
	
	# We need to dereference the referenced arguments 
	# before using them, by prepending the symbol showing
	# the type of referenced arguments (e.g., @ for arrays).
	my(@genes1) = @$genes1_ref;
	my(@genes2) = @$genes2_ref;
 
	my($new_dna);

	$new_dna = $genes1[0].$genes1[1].$genes2[0].$genes2[1];

	return $new_dna;
}

my @genes1 = ('AA', 'CC');
my @genes2 = ('GG', 'TT');

# To call a subroutine pass by reference, preface the argument 
# names with a backslash.
print concatenate_dna(\@genes1, \@genes2),"\n";

exit;