Leser: 2
|< 1 2 >| | 19 Einträge, 2 Seiten |
foo(\%hash);
1
2
3
4
5
6
7
8
9
10
11
sub foo {
my $href = shift;
# Arbeit mit Referenz Hash
foreach my $key (keys %$href) {
my $value = $href->{$key};
print "$key => $value\n";
}
}
my %hash = ('a'=>1, b=>2);
foo(\%hash)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my %hash = ( foo => 42, bar => '0815', buz => 'Woodstock' );
sub foo {
my %hash = %{shift @_}; # use warnings!
warn Dumper \%hash;
}
foo(\%hash);
warn Dumper(\%hash);
1
2
3
4
5
6
7
8
9
sub foo {
my %hash = shift;
print $hash{hallo};
}
my %hash;
$hash{hallo} = "welt";
foo(%hash);
1 2 3 4 5 6 7 8 9
sub foo { my %hash = @_; print $hash{hallo}; } my %hash; $hash{hallo} = "welt"; foo(%hash);
1 2 3 4 5 6 7 8 9
sub foo { my %hash = %{shift @_}; print $hash{hallo}; } my %hash; $hash{hallo} = "welt"; foo(\%hash);
warn Dumper(\%hash);
|< 1 2 >| | 19 Einträge, 2 Seiten |