Hi Perl folks,
I am having problems printing elements from an array at runtime.
I wish to push elements into array at runtime and the print it later.
Now I wish to print this matrix using colors.
So I do something like this to enter the runtime values in array:
for(my $i = 0; $i < $#block_array_750; $i++)
{
if ($compare_var eq $block_array_750[$i])
{
#print "Val: $block_array_750[$i],Hash: $running_hotfix_hash{$key} Plat: $platform\n";
if ($running_hotfix_hash{$key} eq "FIN") { $status = BOLD WHITE "FIN", RESET; }
if ($running_hotfix_hash{$key} eq "RUN") { $status = BOLD RED "RUN", RESET; }
if ($running_hotfix_hash{$key} eq "INP") { $status = BOLD GREEN "INP", RESET; }
if ($running_hotfix_hash{$key} eq "HLD") { $status = BOLD WHITE "HLD", RESET; }
if ($running_hotfix_hash{$key} eq "CAN") { $status = BOLD WHITE "CAN", RESET; }
if ($running_hotfix_hash{$key} eq "PND") { $status = BOLD YELLOW "PND", RESET; }
if ($platform eq "HP") {$block_array_750[$i+1] = $status;}
if ($platform eq "HPX") {$block_array_750[$i+2] = $status;}
if ($platform eq "SUN") {$block_array_750[$i+3] = $status;}
if ($platform eq "AIX") {$block_array_750[$i+4] = $status;}
}
}
Now sometime later in code, I am printing this array:
sub DisplayMatrix
{
print "\n";
for (my $i =0; $i < $#array_750; $i++)
{
print "\t\t\t$array_750[$i]\t\t$array_750[$i+1]\t\t$array_750[$i+2]\t\t$array_750[$i+3]\t\t$array_750[$i+4]\n";
$i += 4;
}
But while printing the matrix, the colored rows are not indented properly. They tend to shift to left or right making the whole indentation unproper.
Just to add more, I observed if I dont use colors the matrix printing is proper. Also those rows are dislocated which have colors in them.
Is this a problem with colors?
How can I use colors and keep the matrix indentation proper?
Please advise.
Thanks.