Hello all,
This thread relates to a thread I started a week or so ago about outputing to a file that KevinADC helped me with. The thread seems to have been deleted, so I will give the details. I have the results of two DB queries in arrays. What I want to do is loop through them, combine them into one into one data structure based on the common element in each, then count the entries in the data structure and output the results to a file. Here is the code Kevin suggested to use:
Here is the problem I am having. I can't figure out how to get the numbers I want into the @data array.
What I am doing is looping through an array called @problem like this:
and then once I have excluded all the tickets I don't want, and count up the tickets if they occured before a certain period or after a certain period etc. I need to get the counts for each somehow into @data for printing:
In other words, with my loop through the @problem array, I can get the counts for the TOTAL number of tickets for ALL Tier levels , severities and types, but what I need is individual counts for each:
In other words:
where the CLOSED 5 column will be the results of the ticket counts for that Tier level, criticality level and device type.
I hope that is not to confusing.
Ant help is appriciated.
Nick
Thanks,
Nick
I got a Biz Degree! How the h*ll did I get here?
This thread relates to a thread I started a week or so ago about outputing to a file that KevinADC helped me with. The thread seems to have been deleted, so I will give the details. I have the results of two DB queries in arrays. What I want to do is loop through them, combine them into one into one data structure based on the common element in each, then count the entries in the data structure and output the results to a file. Here is the code Kevin suggested to use:
Code:
my %Tickets = ();
while(<FILE>){
chomp; #if necessary
# get you data into the list of scalars you posted
# in your first post
my @data = qw($numberprgn $assignment $uis_elapsed_start_time $close_time $res_anal_code $user_priority $subtype $uis_support_level $uis_fstatus);
for my $i (0..8) {
$Tickets{$uis_tier}{$severity_code}{$type}[$i]+=$data[$i];
}
# finished building records
# print records to file
open (FILE,">records.txt") or die "$!";
flock(FILE, 2);
foreach my $tiers (keys %Tickets) {
foreach my $severity (keys %{ $Tickets{$tiers} }) {
foreach my $type (keys %{ $Tickets{$tiers}->{$severity_code} }) {
print FILE "$tiers,$severity,$type," . join(',',@{ $Tickets{$tiers}->{$severity}->{$type} }) . "\n";
}
}
}
close(FILE);
Here is the problem I am having. I can't figure out how to get the numbers I want into the @data array.
What I am doing is looping through an array called @problem like this:
Code:
foreach $prob (@problem) {
chomp $prob;
my ($company, $logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time, $res_anal_code, $user_priority,
$severity_code ) = split (/,/, $prob);
# Perfom a bunch of exclusions
next unless ($logical_name ~= /xyz/);
next unless (etc. etc. etc.);
# Now I perform a buch of counts as in
if ($close_date < $rpt_date) {$count1++;)
and then once I have excluded all the tickets I don't want, and count up the tickets if they occured before a certain period or after a certain period etc. I need to get the counts for each somehow into @data for printing:
Code:
$Tickets{$uis_tier}{$severity_code}{$type}[$i]+=$data[$i];
In other words, with my loop through the @problem array, I can get the counts for the TOTAL number of tickets for ALL Tier levels , severities and types, but what I need is individual counts for each:
Code:
$Tickets{$tiers}->{$severity}->{$type}
In other words:
Code:
CLOSED OPENED etc.
Tier1->Critical->Router 5 10 etc.
where the CLOSED 5 column will be the results of the ticket counts for that Tier level, criticality level and device type.
I hope that is not to confusing.
Ant help is appriciated.
Nick
Thanks,
Nick
I got a Biz Degree! How the h*ll did I get here?