Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#
# Build a month lookup table
#
my %months = (
"01" => "January" ,
"02" => "February" ,
"03" => "March" ,
"04" => "April" ,
"05" => "May" ,
"06" => "June" ,
"07" => "July" ,
"08" => "August" ,
"09" => "Spetember" ,
"10" => "October" ,
"11" => "November" ,
"12" => "December"
);
#
# Determine the month and year for the report to run
#
$rpt_yr = $year;
if ($month == 01) {
$rpt_month = 12;
$rpt_yr = $rpt_yr - 1;
}
if ($month < 10) {
$rpt_month = ("0" . ($month -1));
}else{
$rpt_month = ($month - 1);
}
print (LOG "Data will be gathered for the month of $months{$rpt_month}\n\n");
#
# Get the months for the 4 month chart
#
my $text_month1 = $months{$rpt_month};
push (@months, $text_month1);
if ($text_month1 eq "January") {
$text_month2 = "December";
}else{
$text_month2 = ($rpt_month - 1);
}
push (@months, $text_month2);
if ($text_month2 eq "January") {
$text_month3 = "December";
}else{
$rpt_month3 = ($rpt_month -2);
}
push (@months, $text_month3);
if ($text_month3 eq "January") {
$text_month4 = "December";
}else{
$rpt_month4 = ($rpt_month -3);
}
push (@months, $text_month4);
print (LOG "Text month array: @months\n\n");
@months=('01','02','03','04',
'05','06','07','08',
'09','10','11','12');
print $months[-4]; # =>09
$curr=2;
@last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
$month=localtime()[4];
$month++;
$curr=$month;
@text =("january", "february", "march",
"april", "may", "june",
"july", "august", "september",
"october", "november", "december");
@months=('01','02','03','04',
'05','06','07','08',
'09','10','11','12');
@last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
@last4text =($text[$curr-4],$text[$curr-3],$text[$curr-2],$text[$curr-1]);
$curr=$rpt_month;
my @text =("January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December");
my @months=('01','02','03','04',
'05','06','07','08',
'09','10','11','12');
my @last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
my @last4text =($text[$curr-4],$text[$curr-3],$text[$curr-2],$text[$curr-1]);
print (LOG "Text month array: @last4months\n\n");
Text month array: 11 12 01 02
#!perl
use strict;
use warnings;
my @mnames = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my %mtable;
@mtable{map {sprintf "%02d",$_} (1..12)} = @mnames;
my $currmth = (localtime)[4] + 1;
my @last4 = map {sprintf "%02d", $_<1? $_+12: $_} ($currmth-4..$currmth-1);
print "$_ => $mtable{$_}\n" for reverse @last4;
02 => Feb
01 => Jan
12 => Dec
11 => Nov
Hello all,
I know I can get a hash value based on the key as in:
my $var = $hash{$key};
but haow can I get a key when I know the value?
my %months = (
"01" => "January" ,
"02" => "February" ,
"03" => "March" ,
"04" => "April" ,
"05" => "May" ,
"06" => "June" ,
"07" => "July" ,
"08" => "August" ,
"09" => "Spetember" ,
"10" => "October" ,
"11" => "November" ,
"12" => "December"
);
my %months_reversed = reverse %months;
print "The key for June is :$months_reversed{'June'}";
#
# Get the start time and date. Print to logfile.
#
my ($sec, $min, $hr, $day, $month, $year, $weekday, $dayofyr, $junk_yuk) = localtime(time);
$month++;
if ($hr < 10) {$hr = "0" . $hr;}
if ($min < 10) {$min = "0" . $min;}
if ($sec < 10) {$sec = "0" . $sec;}
if ($month < 10) {$month = "0" . $month;}
if ($day < 10) {$day = "0" . $day;}
$year = $year + 1900;
#
# Determine the month and year for the report to run
#
my $rpt_yr = $year;
if ($month == 01) {
$rpt_month = 12;
$rpt_yr = $rpt_yr - 1; # PAUL, THIS WAS MY FIRST BRUSH AT HANDLING THE YEAR TRANSITION NO GOOD!
}
if ($month < 10) {
$rpt_month = ("0" . ($month -1));
}else{
$rpt_month = ($month - 1);
}
#
# Build a month lookup table
#
my %months = (
"01" => "January" ,
"02" => "February" ,
"03" => "March" ,
"04" => "April" ,
"05" => "May" ,
"06" => "June" ,
"07" => "July" ,
"08" => "August" ,
"09" => "Spetember" ,
"10" => "October" ,
"11" => "November" ,
"12" => "December"
);
print (LOG "Data will be gathered for the month of $months{$rpt_month}\n\n");
#
# Get the months for the 4 month chart
#
my $curr=$rpt_month;
my @text =("January", "February", "March",
"April", "May", "June",
"July", "August", "September",
"October", "November", "December"
);
my @months =('01','02','03','04',
'05','06','07','08',
'09','10','11','12'
);
my @last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
my @last4text =($text[$curr-4],$text[$curr-3],$text[$curr-2],$text[$curr-1]);
print (LOG "Months for 4 month chart: $last4months[0],$last4months[1],$last4months[2],$last4months[3]\n\n");
$rpt_month = $last4months[3];
################################################################################################
#
# Count open, closed and backlog tickets for each month of the 4 months chart. We will use these
# for the one months charts as well.
#
################################################################################################
#
# Closed tickets for last 4 months
#
if ($close_month eq $last4months[0]) {
$closed_cnt{$last4months[0]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
#print CLOSE0 "$_\n";
}
if ($close_month eq $last4months[1]) {
$closed_cnt{$last4months[1]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
#print CLOSE1 "$_\n";
}
if ($close_month eq $last4months[2]) {
$closed_cnt{$last4months[2]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
#print CLOSE2 "$_\n";
}
if ($close_month eq $rpt_month) {
$closed_cnt{$rpt_month}++;
# Uncomment the line below to dump the tickets counted for this count to a file
#print CLOSE3 "$_\n";
}
#
# Closed tickets for last 4 months
#
if (($close_month eq $last4months[0]) && ($close_year eq $rpt_yr)) {
$closed_cnt{$last4months[0]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
print CLOSE0 "$_\n";
}
if (($close_month eq $last4months[1]) && ($close_year eq $rpt_yr)) {
$closed_cnt{$last4months[1]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
print CLOSE1 "$_\n";
}
if (($close_month eq $last4months[2]) && ($close_year eq $rpt_yr)) {
$closed_cnt{$last4months[2]}++;
# Uncomment the line below to dump the tickets counted for this count to a file
print CLOSE2 "$_\n";
}
if (($close_month eq $rpt_month) && ($close_year eq $rpt_yr)) {
$closed_cnt{$rpt_month}++;
# Uncomment the line below to dump the tickets counted for this count to a file
print CLOSE3 "$_\n";
}
if (($close_month eq $last4months[1]) && ($close_year eq $rpt_yr) [b]|| $close_year == ($rpt_yr-1)[/b]))
my @last4months=($months[$curr-4],$months[$curr-3],$months[$curr-2],$months[$curr-1]);
[COLOR=red]$ly = 0; #init var
foreach (@last4months) { # iterate over last 4 months
if ($_ >= 10) { # if its greater than oct, it was last year
$last4years[$ly]=$year-1;
} else { # else its this year
$last4years[$ly]=$year;
}
$ly++; #increase counter
}
[/color]