T
Taylor Venable
Hello all,
I have some text in a file, that I'm scanning over and pulling out of
columns for use in some graphs. One piece of the code, however, is
bothering me because a variable seems to suddenly become undefined for no
reason. Here's the code:
my $i = 0;
385: while ($i < $timeMax + .01) {
print "DOOD - timeMax undef!\n" if (not defined $timeMax);
print "$i:$timeMax";
unshift @xs, $i;
unshift @ys, scalar (grep { $_ > $i && $_ < $i + 0.01 } @times);
390: $i += .01;
}
This is for a histogram graph, so I'm finding the number of entries in the
data set that fall in the current range, starting at zero and going up
until the maximum. I know it's not perfect, but for now I'd settle for any
results period, because at the moment the output is:
0.35:0.380084
0.36:0.380084
0.37:0.380084
0.38:0.380084
0.39:0.380084
Use of uninitialized value in addition (+) at ./stress.pl line 385,
<$opt{...}> line 20.
DOOD - timeMax undef!
Use of uninitialized value in concatenation (.) or string at ./stress.pl
line 387, <$opt{...}> line 20.
0:Use of uninitialized value in addition (+) at ./stress.pl line 390,
<$opt{...}> line 20.
So it seems that $timeMax is suddenly undef'd while inside the loop. How
can this be? The numbers I'm pulling from the file are at the end of the
line and haven't been chomp()'d, but I wouldn't think that should matter.
Great thanks for any help.
Taylor Venable
I have some text in a file, that I'm scanning over and pulling out of
columns for use in some graphs. One piece of the code, however, is
bothering me because a variable seems to suddenly become undefined for no
reason. Here's the code:
my $i = 0;
385: while ($i < $timeMax + .01) {
print "DOOD - timeMax undef!\n" if (not defined $timeMax);
print "$i:$timeMax";
unshift @xs, $i;
unshift @ys, scalar (grep { $_ > $i && $_ < $i + 0.01 } @times);
390: $i += .01;
}
This is for a histogram graph, so I'm finding the number of entries in the
data set that fall in the current range, starting at zero and going up
until the maximum. I know it's not perfect, but for now I'd settle for any
results period, because at the moment the output is:
0.35:0.380084
0.36:0.380084
0.37:0.380084
0.38:0.380084
0.39:0.380084
Use of uninitialized value in addition (+) at ./stress.pl line 385,
<$opt{...}> line 20.
DOOD - timeMax undef!
Use of uninitialized value in concatenation (.) or string at ./stress.pl
line 387, <$opt{...}> line 20.
0:Use of uninitialized value in addition (+) at ./stress.pl line 390,
<$opt{...}> line 20.
So it seems that $timeMax is suddenly undef'd while inside the loop. How
can this be? The numbers I'm pulling from the file are at the end of the
line and haven't been chomp()'d, but I wouldn't think that should matter.
Great thanks for any help.
Taylor Venable