3 #=======================================================================
5 # File ID: 524e5f42-5d39-11df-a9d4-90e6ba3022ac
6 # Samler en masse tidspunkter i epoch-format på for eksempel samme dag
7 # eller hver time. Forventer antall sekunder siden 19700101T000000Z
9 #=======================================================================
17 our ($opt_d, $opt_h, $opt_s, $opt_w) =
24 my $Lowest = 4_294_967_295
; # Hm. Æ sei ikkje meir. 2³²-1
29 if (defined($ARGV[0]) && !($ARGV[0] =~ /[^0-9]/)) {
34 if ($opt_s =~ /^\d+$/) {
38 if ($opt_d =~ /^\d+$/) {
39 $Period += $opt_d * 86400;
42 if ($opt_w =~ /^\d+$/) {
43 $Period += $opt_w * 7*86400;
46 $Period || ($Period = 86400);
50 my $Curr = int($1/$Period);
51 $Lowest = $Curr if ($Curr < $Lowest);
52 $Highest = $Curr if ($Curr > $Highest);
55 warn("Line $.: Invalid line format");
59 for (my $Check = $Lowest; $Check < $Highest; $Check++) {
60 defined($Data{$Check}) || ($Data{$Check} = 0);
63 # @tmp_array-prosjektet er en nødløsning for å få sortert utdataene.
67 while (my ($Num, $Val) = each %Data) {
68 push(@tmp_array, sprintf("%u\t%u\n",
69 ($Num * $Period) + int($Period / 2),
75 if (open(TmpFP
, "| sort -n")) {
81 die("Can’t open pipe: $!");
89 Syntax: $0 [options] [file [more files [even more [you get the point]]]]
93 -d N Use N days as period
94 -n Generate data up to current time, guarantees complete periods,
95 but data values may vary when executed at different timepoints.
96 -s N Use N seconds as period
97 -w N Use N weeks as period