Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with push 2

Status
Not open for further replies.

nfaber

Technical User
Oct 22, 2001
446
US
Hello all,

can someone tell me what is wrong with this push?

Code:
				push (@data,$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date);

I know the scalars have values, but nothing is pushed into the array.

I got a Biz Degree! How the h*ll did I get here?
 
There's nothing wrong with it - even if the scalars don't have values, 10 undef values should be added to @data. Can you post the code in-context?
 
I a foreach loop

Code:
foreach $dev(@device) {
my ($assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus) = split (/,/,$dev);
print "$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus";
push (@data,"$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus");
}

While this is not the whole loop, my "push" is the next line after the "print". Everything is printing fine, but nothing is pushed.



I got a Biz Degree! How the h*ll did I get here?
 
I'm stumped here. I am scoping @data global at the start of my script, so thats not it. Here is the whole loop:

Code:
	foreach $prob (@problem) { # Start Problem Table loop
		#
		#  Problem Table processing
		#
		 chomp $prob;
		 my ($company, $logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time, $res_anal_code,
		 	$user_priority, $severity_code ) = split (/,/, $prob);
		 next unless ($logical_name);
		 
		 #
		 # Exclude entries where the dates are non digits (headings)
		 #
		 next unless {($uis_elapsed_start_time =~ /\d+/) || ($close_time =~ /\d+/)};
		 ###############################################################################################
		 #
		 #  Problem Table exceptions
		 #
		 ###############################################################################################
		 #
		 #  Exception for Morgan Stanley
		 #
		 if ($key eq "mwd") {$severity_code = $user_priority;}
		 #
		 # Exceptions for International Paper
		 #
		 if ($key eq "ipa") { 
			 next unless ($logical_name =~ /\.na\.ipa$/i);
		 }
		 if ($key eq "ipi") { 
			 next unless ($logical_name =~ /\.na\.ipi$/i);
		 }
		 #
		 #  Joint customer exceptions
		 #
		 if ($key =~ /^com|gld|mmc|npa|pjc|shr|thc|trc|plx|lmr|mwd$/) {
			next unless ($logical_name =~ /\.na\.$key$/i);
		 }		 
		 #
		 # Split ticket open and close dates into chunks
		 #
		 my ($open_month, $open_day, $open_year, $junk2) = split (/-/,$uis_elapsed_start_time);
		 my ($close_month, $close_day, $close_year, $junk1) = split (/-/,$close_time);
		 #
		 # Count open and closed tickets for each month of the 4 months chart. We will use these
		 # for the one months chart as well.
		 #
		 #
		 # Closed tickets for last 4 months
		 #
		 if ($close_month	== $last4months[0]) {$closed_cnt{$last4months[0]}++;}
		 if ($close_month	== $last4months[1]) {$closed_cnt{$last4months[1]}++;}
		 if ($close_month	== $last4months[2]) {$closed_cnt{$last4months[2]}++;}
		 if ($close_month	== $last4months[3]) {$closed_cnt{$last4months[3]}++;}
		 #
		 # Opened tickets last 4 months
		 #
		 if ($open_month	== $last4months[0]) {$open_cnt{$last4months[0]}++;}
		 if ($open_month	== $last4months[1]) {$open_cnt{$last4months[1]}++;}
		 if ($open_month	== $last4months[2]) {$open_cnt{$last4months[2]}++;}
		 if ($open_month	== $last4months[3]) {$open_cnt{$last4months[3]}++;}
		 #
		 # Ending backlog last 4 months
		 #
		 if ($open_month	== $last4months[0] && $close_month != $last4months[0]) {$end_backlog{$last4months[0]}++;}
		 if ($open_month	== $last4months[1] && $close_month != $last4months[1]) {$end_backlog{$last4months[1]}++;}
		 if ($open_month	== $last4months[2] && $close_month != $last4months[2]) {$end_backlog{$last4months[2]}++;}
		 if ($open_month	== $last4months[3] && $close_month != $last4months[3]) {$end_backlog{$last4months[3]}++;}
		 #
		 # Starting backlog. We only need it for the current month
		 #
		 if ($open_month < $last4months[3]) {
		 	$start_backlog{$last4months[3]}++ unless ($close_month);
		 	$start_backlog{$last4months[3]}++ if ($close_month > $last4months[3] );
		 }
		# if ($open_month	< $last4months[1] && $close_month > $last4months[1]) {$start_backlog{$last4months[1]}++;}
		# if ($open_month	< $last4months[2] && $close_month > $last4months[2]) {$start_backlog{$last4months[2]}++;}
		 #if ($open_month	< $last4months[3] && $close_month > $last4months[3]) {$start_backlog{$last4months[3]}++;}

		 #
		 # Exclude tickets closed before beginning, or opened after the end of the report period, then
		 # count each.
		 #
		next if ($close_month < $rpt_month || $close_year < $rpt_yr); # exclude closed before beginning
		next if ($open_month > $rpt_month || $open_year > $rpt_yr); #exclude open after end
		 if ($close_month == 01) {
			$close_month = 13;
		}
			#
			# Build and array of valid tickets for the report month. We will
			# be using this later.
			#
			push (@prob_except, $prob);
		 
		 #
		 # Get Problem type at resolution. Build a list of uniq problem types (res_anal_codes).
		 #
		 if ($close_month == $rpt_month) {
			$close_cnt++; # Tickets Closed during the current month
			next if ($res_anal_code =~ /cancel/i);
			next if ($res_anal_code =~ /duplicate/i);
			next if ($res_anal_code =~ /testing/i);
			next if ($res_anal_code =~ /information/i);
			#print "Res anal code:\t$res_anal_code\n";
			#
			# Count up the Problem types at resolution
			#
			if 	($res_anal_code =~ /customer/i) 	{$changes++;}
			elsif 	($res_anal_code =~ /telco/i) 		{$telco++;}
			elsif 	($res_anal_code =~ /power/i) 		{$power++;}
			elsif 	($res_anal_code =~ /server/i) 		{$server++;}
			elsif 	($res_anal_code =~ /application/i) 	{$application++;}
			else {$other++;}
		 }
		 #
		 #  Handle defaults
		 #
		 unless ($severity_code) {$severity_code="critical";}
		 unless ($user_priority) {$user_priority = "S1";}
		 #
		 #
		 #  For each entry in the problem table, loop through the device table, perform device table exclusions
		 #  then match the logical_name from the problem table query with the logical_name from the device table
		 #  query and if a match is found, populate the merge hash with the device table matching fields. If
		 #  a match is not found, use default data to fill the hash with device table information.
		 #
		 #
		 foreach $dev (@device) { # Start Device Table loop.
			#
			# Device Table Processing
			#
			chomp $dev;
			($log_name, $type, $subtype, $uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date ) = split (/,/, $dev);
			#select logical_name, type, subtype, uis_support_level, uis_tier, uis_fstatus, uis_managed_date, uis_deactivated_dat
			########################################################################################
			#
			#  Device Table exceptions
			#
			########################################################################################
			#
			#  Joint customer exceptions
			#
			if ($key =~ /^com|gld|mmc|npa|pjc|shr|thc|trc|plx|lmr|mwd$/) {
				next unless ($logical_name =~ /\.na\.$key$/i);
			}
			next if ($log_name	=~ /default/i	);
			next if ($log_name	=~ /imac/i	);
			next if ($type		=~ /circuit/i	);
			#
			#  Build a list of unique device types 
			#
			#$prob_type{$type} = "null";
			#
			# Build a list of types for each ticket
			#
			#print LOG "DEV = $log_name\tPROB = $logical_name\n";
			if ($log_name eq $logical_name) {
				#
				# Merge it all
				#
				$match_cnt++;
				push (@data,"$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus");				
			#print (LOG "merge for equal is = $Tickets\n");
			#  
			#  Could not find a match in the device table query. Populate the hash with default values
			#
			}elsif ($log_name ne $logical_name) { # Start logical name match loop.

				#
				# Assign default value to type based on assignment
				# 
				if ($assignment		=~ /nccbb/i) {
					$type = "Network";
				}elsif ($assignment =~ /smcbb/i) {
					$type = "System";
				}elsif ($assignment =~ /sccbb/i) {
					$type = "Security"
				}elsif ($assignment =~ /iptbb/i) {
					$type = "VOIP";
				}
				#
				# Assign default value to uis_tier
				#
				$uis_tier = "Tier 1";
				#
				# Assign default value to subtype
				#
				$subtype = "NULL";
				#
				# Assign default value to uis_support_level
				#
				$uis_support_level = "NULL";
				#
				# Merge it all
				#
				$merge{$numberprgn} = ("$logical_name, $numberprgn, $assignment, $uis_elapsed_start_time, $close_time,
							$res_anal_code, $user_priority,	$severity_code, $type, $subtype,
							$uis_support_level, $uis_tier, $uis_fstatus, $uis_managed_date, $uis_deactivated_date"); 
	
				print "$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus";
				push (@data,"$assignment, $res_anal_code, $user_priority, $severity_code, $type, $uis_support_level, $uis_tier, $uis_fstatus");
				$nomatch_cnt++;
				# finished building records
			} # End logical name match loop.			
		 } # End Device Table loop.	
	} # End Problem Table Loop

is this part ok?

Code:
		 if ($open_month < $last4months[3]) {
		 	$start_backlog{$last4months[3]}++ unless ($close_month);
		 	$start_backlog{$last4months[3]}++ if ($close_month > $last4months[3] );
		 }

I got a Biz Degree! How the h*ll did I get here?
 
get rid of the double quotes in the push() arguments and see if that helps.
 
You've got double quotes around all your variables in your second snippet, which is different to what you posted originally.

In your original post, you're adding each of those variables to your @data array and in the second, you're adding a single string, consisting of a comma-seperated joining of those variables.

Which one are you trying to achieve?

Again, there's nothing wrong with the syntax - one element should be added to @data for each element in @device. Make sure you're not redeclaring @data anywhere else - do you have warnings turned on?

<possible over-childishness>
You might want to consider typing the entirity of $res_analysis_code - it looks better!
</possible over-childishness>
 
I've tried it both ways, with the quotes and without. Same result.

I got a Biz Degree! How the h*ll did I get here?
 
ishnid, I have to admit, I got a chuckle out of that too :)
 
the push lines are OK, but if you use double-quotes I have a feeling it will make the entire group of strings one element of @data instead of separate elements, but I'm not sure.

My gut feeling is that you are redefining @data later and possibly emptying it out or deleting it. I'll bet if you print @data at the very end of all that it will contain something, even if just null elements.
 
The problem was a larger logic problem. Now corrected.

Sorry...stars for all

I got a Biz Degree! How the h*ll did I get here?
 
BTW..the "res_anal_code" is straight from a DB query. I just made the query name titles the same name as the variables.

I got a Biz Degree! How the h*ll did I get here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top