Help for this page

Select Code to Download


  1. or download this
    sub pass_by_value {
      my $value = shift;
      print $value++, "\n";
    ...
    my $x = 0;
    pass_by_value($x) for ( 1 .. 5 );
    pass_by_reference(\$x) for ( 1 .. 5 );
    
  2. or download this
    foreach my $pair ( [9,5],[0,3],[6,8],[8,3] ) {
      my ($a, $b) = @$pair;
      my $min = ($a < $b) ? \$a : \$b;
    ...
      # changes are then reflected in $a or $b
      print "$a ; $b\n";
    }