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

bloonix
 2005-12-21 21:19
#61016 #61016
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
Hallo zusammen,

ich habe das Modul nochmal ein wenig auf den Kopf gestellt und eine
Methode namens new hinzugefügt. Ich habe bisher noch nicht viel mit
OO zu tun gehabt. Ist die Methode so ok?

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
sub new {
  my $Class = shift;
  my %Param;

  if (ref $_[0] eq 'HASH') {
     %Param = %{$_[0]};
  }
  elsif (@_ & 1) {
     die 'Statistics: not enough arguments ...';
  }
  else {
     %Param = @_;
  }

  for (keys %Param) {
     die "Statistics: invalid argument $_"
        unless /^(SysInfo|ProcStats|MemStats|PgSwStats|NetStats|SockStats|DiskStats|DiskUsage|LoadAVG|Processes|TimePoint)$/;
  }

  my $Self = bless(\%Param,$Class);

  return $Self;
}

sub getStats {
  my $Param = shift;
  my $Class = shift;

  ...
  ...
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