27 9月 2007

[Perl] swap()

sub swap{
( $_[0], $_[1] ) = ( $_[1], $_[0] );
}


my $a = 100;
my $b = 200;

swap($a, $b);

print $a . ", " . $b . "n";

#結果會是200, 100

沒有留言: