Thread Hash als Option missbrauchen (118 answers)
Opened by bloonix at 2005-12-19 02:24

bloonix
 2005-12-19 18:59
#60987 #60987
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Code: (dl )
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 );


Jo, ich habs. Klappt beides, obwohl man sich eventuell noch über die
Syntax streiten könnte :-)

Danke für die Hilfe.
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Hash als Option missbrauchen