Ley, Chung wrote:
I didn't know the use of Data::Dumper, wish I had known it earlier...
Basically,
I was trying to mimic what the Boxplot.pl was doing, and so I did a loop like
this:
for (my $k; defined $data[0][1][$k]; $k++ )
{
print "data[0][1][$k] is defined\n";
print "data[0][1][$k] = $data[0][1][$k];\n";
}
I discovered that I have a number of elements that are defined but with no real
values....
I have never used the "Devel-ebug" before, I will try to learn...
But in trying to "replicate" the same problem, I seem to find something that is
odd... Basically, instead of "looping" thru all the data, I mimic the same
place
where I am having the problem by "hard-coding" the data array for just ONE very
simple boxplot based on real data(see later). The code works when I put it in
its
own file - no warnings... But it doesn't work when I am running it in my "main"
program! The warnings are something like these:
Use of uninitialized value in array element at
/usr/lib/perl5/site_perl/5.8.0/GD/Graph/boxplot.pm line 470.
Use of uninitialized value in array element at
/usr/lib/perl5/site_perl/5.8.0/GD/Graph/boxplot.pm line 472.
Use of uninitialized value in numeric gt (>) at
/usr/lib/perl5/site_perl/5.8.0/GD/Graph/boxplot.pm line 472.
The problem is that the initial value in $k is undef so you should change:
for (my $k; defined $data[0][1][$k]; $k++ )
To:
for (my $k = 0; defined $data[0][1][$k]; $k++ )
Perhaps what you really want to do is:
for my $k ( 0 .. $#{$data[0][1]} )
{
print "data[0][1][$k] is defined\n";
print "data[0][1][$k] = $data[0][1][$k];\n";
}
So, I was curious... Basically, I then "move" this hardcoding to the "very
beginning" of my main program BEFORE even my variable declarations and etc, and
it
still had the same warnings!!! I am dumbfounded... I am thinking that somehow
maybe the perl compiler/interpreter is doing some optimzation that is different
when the "size" of your perl program is at a different size????
First Code
sampe::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#!/usr/bin/perl
$| = 1; # AutoFlush
use strict;
use warnings;
use DBI;
use GD;
use Benchmark;
use POSIX;
use TSGPlot;
my (@data, $ret);
$data[0][0] = 'AMD133';
push (@{$data[1][0]}, 97.6);
push (@{$data[1][0]}, 97.5);
push (@{$data[1][0]}, 98.4);
push (@{$data[1][0]}, 96.4);
push (@{$data[1][0]}, 95.5);
push (@{$data[1][0]}, 97.1);
push (@{$data[1][0]}, 97.5);
push (@{$data[1][0]}, 100.0);
push (@{$data[1][0]}, 98.4);
Instead of pushing nine elements onto the array separately you can push the
whole list at once:
push @{$data[1][0]}, 97.6, 97.5, 98.4, 96.4, 95.5, 97.1, 97.5, 100.0,
98.4;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>