A while ago I posted a question about a loop in a loop. Here is the basic structure:
The "last" is the problem. For each enrty in @problem I need to search through each enrty in @device and look for a match for $log_name eq $logical_name and if found, populate the %merge hash with the real values, if not found, assign defaults to all variables.
The way my loop is working, it only gets to the first entry in @device as the "last" command is always encountered.
Thanks,
Nick
I got a Biz Degree! How the h*ll did I get here?
Code:
foreach (@problem) {
my ($company, $logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time, $res_anal_code,$user_priority, $severity_code ) = split (/,/);
$problem{$logical_name}=($_);
foreach (@device) {
($log_name, $type, $subtype, $uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date ) = split (/,/);
if (exists $problem{$log_name}) {#Look for a match.
my @afh = ("$logical_name,$numberprgn,$assignment,$open_month,$close_month,$open_year,$close_year,$rpt_yr,$rpt_month,$res_anal_code,$severity_code,$type,$uis_support_level,$uis_tier,$uis_fstatus,$uis_managed_date,$uis_deactivated_date");
$merge{$numberprgn} = [@afh];
last;
}else{
#Set defaults since a match was not found.
my @afh = ("$logical_name,$numberprgn,$assignment,$open_month,$close_month,$open_year,$close_year,$rpt_yr,$rpt_month,$res_anal_code,$severity_code,$type,$uis_support_level,$uis_tier,$uis_fstatus,$uis_managed_date,$uis_deactivated_date");
$merge{$numberprgn} = [@afh];
last;
}
The "last" is the problem. For each enrty in @problem I need to search through each enrty in @device and look for a match for $log_name eq $logical_name and if found, populate the %merge hash with the real values, if not found, assign defaults to all variables.
The way my loop is working, it only gets to the first entry in @device as the "last" command is always encountered.
Thanks,
Nick
I got a Biz Degree! How the h*ll did I get here?