in reply to Spurious `undefined' values and conversion issues
$counts_rebin[$k] = ($counts_rebin[$k] + $value); # l:1153
Try writing that line this way, and that warning will go away (in this case, the warning is just a matter of style -- no impact on the final results):
$counts_rebin[$k] += $value; # l:1153
unin. val in multiplication (line 1158)
That bit is in a for loop that goes up to "$j==16831" -- are you sure you have that many elements in @rawchannel?my $totcount = $rawchannel[$j]; my $split1 = (($energy_before[$j]-$energy_rebin[$k])*$totcount) +/($energy_before[$j]-$energy_before[${j}-1]); # l:1158
unin. val in subtraction (line 1162),
Probably the same issue as the previous one, relating to $totcount (and @rawchannel), but I can't say for sure.$counts_rebin[$k]=($counts_rebin[$k]+($totcount-$split1)); # l +:1162
unin. val. in numeric ge (>=) in line 1148
if(($energy_rebin[$k] >= $energy_before[$j])){ # l:1148
I think there may be something odd going on with how you are incrementing $k inside the main for loop ($j=0..16381) -- maybe it's getting incremented to far? But that's just a guess. Maybe the "until" loop at line #1168 should be done like this:
That would make sure that $k never points to an uninitialized offset in that array (but I don't know if it does the right thing as far as your algorithm is concerned).until ($k==@energy_rebin or $energy_rebin[$k]>=$energy_bef +ore[$j]){ $k += 1; }
Modification of a read-only value attempted at line 1188
I really don't understand why you are using "printf" there -- it makes no sense to me. Wouldn't you rather take the value returned by "pack" and just "print" it?printf REBINOUT pack('V',$counts_rebin[$i]); # l: 1188
(update: the first item -- line #1153 -- is one of many examples where your coding style is more fortran-like rather than perlish (or even C-like), which I suppose is not unexpected for this sort of app... And the last item (printf) might be a symptom of C-centric style. Of course, you don't need to make it "more perlish" just for the sake of doing that, but increasing the use of some of the more compact perl idioms might be a good thing.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Spurious `undefined' values and conversion issues
by sf_ashley (Sexton) on May 30, 2008 at 18:36 UTC |