Help for this page

Select Code to Download


  1. or download this
    sub mysub { 
        my @array = @$_[0];    # Makes a copy. Not efficient.
    ...
    my @a = (1 .. 10);
     
    mysub(\@a);    # \@a is a reference to the array @a.
    
  2. or download this
    mysub { 
        my @array = @_;    # Copying again. Not efficient.
    ...
    my @a = (1 .. 10); 
    
    mysub(@a);    # Send the array as @_
    
  3. or download this
    mysub {
        my ($arrayref) = @_;
    ...
    my @a = (1 .. 10); 
    
    mysub( \@a );