98_count.pm 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # $Id: 98_count.pm 11992 2016-08-19 18:18:00Z betateilchen $
  2. package main;
  3. use strict;
  4. use warnings;
  5. sub count_Initialize($$) {
  6. $cmds{count} = { Fn => "CommandCount",
  7. Hlp=>"[filter],count devices"};
  8. }
  9. sub CommandCount($$)
  10. {
  11. my ($cl, $param) = @_;
  12. my $str = "";
  13. my $fill = "";
  14. my $n = 0;
  15. if(!$param) { # List of all devices
  16. $n = keys %defs;
  17. $fill = "s" if $n != 1;
  18. $str = "\nCount: $n device$fill in total.\n";
  19. } else { # devspecArray
  20. $n = 0;
  21. my @list = devspec2array($param,$cl);
  22. $n = int(@list);
  23. if ($n == 1) {
  24. $n = (defined($defs{$list[0]})) ? 1 : "No";
  25. $fill = "s" if ($n eq "No");
  26. } else {
  27. $fill = "s"
  28. }
  29. $str = "\nCount: $n device$fill for devspec $param\n";
  30. }
  31. return $str;
  32. }
  33. 1;
  34. =pod
  35. =item summary count devices based on devspec
  36. =item summary_DE zählt Geräte, die einer devspec entsprechen
  37. =item command
  38. =begin html
  39. <a name="count"></a>
  40. <h3>count</h3>
  41. <ul>
  42. <code>count [devspec]</code>
  43. <br><br>
  44. Count devices specified by devspec.<br/>
  45. If no devspec given, count will return number of totally defined devices.<br/>
  46. </ul>
  47. =end html
  48. =cut