173

References & Structures
References as Parameters

  • References can be passed as subroutine parameters

      @foo = ( 1..10 );
      @bar = ( 'a'..'z' );
      &Test( \@foo, \@bar );

  • The references may then be dereferenced inside the subroutine
      sub Test {
      	$list1 = shift( @_ );
      	$list2 = shift( @_ );
      	print "list1 ", @$list1, "\n";
      	print "list2 ", @$list2, "\n";
      }