I've been playing with some code to assign a zero to a variable if undefined but it is not working. This is excerts from a larger program.
Here's the output I am getting:
Any help is appriciated.
Nick
I got a Biz Degree! How the h*ll did I get here?
Code:
my ($changes,$telco,$application,$server,$other) = 0;
foreach $res_anal_code (@res_code) {
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++;}
}
my @array = ("$changes","$server","$telco","$application","$other");
foreach (@array) {
unless (defined($_)) {
$_ = 0;
}
}
print OUT "problemType chart:\n";
print (OUT "type, number\n" );
print (OUT "changes,$changes\n" );
print (OUT "server,$server\n" );
print (OUT "power,$power\n" );
print (OUT "telco,$telco\n" );
print (OUT "application,$application\n" );
print (OUT "other,$other\n\n" );
Here's the output I am getting:
Code:
problemType chart:
type, number
changes,635
server,
power,119
telco,334
application,
other,484
Any help is appriciated.
Nick
I got a Biz Degree! How the h*ll did I get here?