Help for this page

Select Code to Download


  1. or download this
    sub swap {
      my ($a, $b) = \(@_);
    ...
    print "($x,$y)";    #> (42,666)
    swap($x,$y);
    print "($x,$y)";    #> (666,42)
    
  2. or download this
    sub swap {
      my $a = \shift;
    ...
      ( $$a, $$b ) = ( $$b, $$a );  
    }
    
  3. or download this
    sub swap { 
       ($_[0], $_[1] ) = ( $_[1], $_[0] ); 
    }