Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my %hash = ();
- while (my $row_ref = $sth->fetchrow_arrayref) {
- my $date = @$row_ref[1];
- my $samples = @$row_ref[2];
- $hash{$date} = $samples;
- }
- for(my $i = $days;$i >= 1;$i--){
- my $myseconds = time - ($i * 86400);
- (my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my $yday, my $isdst) = localtime($myseconds);
- $year = $year+1900;
- $mon = $mon+1;
- if($mon<10){
- $mon = "0$mon";
- }
- if($mday<10){
- $mday="0$mday";
- }
- my $mydate = $year. "-" .$mon. "-" .$mday;
- print $mydate ." samples: ";
- if(exists $hash{$mydate}){
- print $hash{$mydate};
- } else {
- print "No samples";
- }
- print "\n";
Add Comment
Please, Sign In to add comment