分类:
2008-07-03 11:06:06
#!/usr/bin/perl -w
use strict;
use warnings;
&main;
sub main {
my @array = (0, 1, 2);
my %hash = (
'0' => 'a',
'1' => 'b',
'2' => 'c'
);
my $scalar = "call by value\n";
refFunction(\%hash, \@array, \$scalar);
print $scalar;
}
sub refFunction {
my($hash, $array, $scalar) = @_;
print "array \n";
foreach(@$array) {
print $_ . "\n";
}
print "hash \n";
foreach my $key(sort keys %$hash) {
print "$key->$hash->{$key}\n";
}
$$scalar = "call by reference";
}