Leser: 1
![]() |
|< 1 2 3 4 5 6 ... 12 >| | ![]() |
119 Einträge, 12 Seiten |
1
2
3
4
5
6
7
sub Statistics {
for (@_) {
warn "Bad argument $_" if ref $_;
}
}
Statistics( 'Key','Value',{ 'Key1' => 'Value1','Key2' => 'Value2' },[ 'Value1','Value2' ] );
1
2
3
4
5
6
7
8
9
sub Statistics {
for (@_) {
die "Bad argument $_" if ref $_;
}
my %param = @_; # line 10
}
Statistics( 'Key1','Value2','Key2' );
die "Not enough arguments" if (@_ / 2) =~ /\./;
1
2
3
4
for (1 .. 10) {
my $var = int(rand(100000)) + 1;
print "$var ist ", (($var & 1) ? "ungerade" : "gerade"), "\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
sub Statistics {
my %param;
if (ref $_[0] eq 'HASH') {
%param = %{$_[0]};
}
elsif (@_ & 1) {
die 'Not enough arguments';
}
else {
%param = @_;
}
print Dumper(%param);
}
Statistics( 'Key1','Value1','Key2','Value2' );
my $hashref = {
'Key1' => 'Value1',
'Key2' => 'Value2',
};
Statistics( $hashref );
![]() |
|< 1 2 3 4 5 6 ... 12 >| | ![]() |
119 Einträge, 12 Seiten |