Fellow mongers;
I am trying to extract a series of numbers from a string of numbers using the following code. When I dump out the resulting contents it appears OK but I am getting a non-numeric content error when trying to convert it to numeric.
Can someone please take a look at this snippet to see what I am missing? Or better yet, advise of a better way to extract values into a field/array element containing numeric values?
Source array $XGLA contains 12 x 13 bytes where each segment contains a number OR blanks. I am extracting each segment into a corresponding array element that must be numeric for arithmetic to be performed.
Code Snippet:
# Extract Monthly Amounts
$Y=0;
for($X=0;$X<13;$X++) {
$GLA[$X]=substr($XGLA,$Y,13);
$GLA[$X]=~s/^\s+//;
$GLA[$X]+=0;
$Y+=13;
}
I am receiving the error on the line that contain
$GLA[$X]+=0;
and ANY other line containing arithmetic ops with that field (and others like it).
Advise please???
Signed: Tired programming grunt
I am trying to extract a series of numbers from a string of numbers using the following code. When I dump out the resulting contents it appears OK but I am getting a non-numeric content error when trying to convert it to numeric.
Can someone please take a look at this snippet to see what I am missing? Or better yet, advise of a better way to extract values into a field/array element containing numeric values?
Source array $XGLA contains 12 x 13 bytes where each segment contains a number OR blanks. I am extracting each segment into a corresponding array element that must be numeric for arithmetic to be performed.
Code Snippet:
# Extract Monthly Amounts
$Y=0;
for($X=0;$X<13;$X++) {
$GLA[$X]=substr($XGLA,$Y,13);
$GLA[$X]=~s/^\s+//;
$GLA[$X]+=0;
$Y+=13;
}
I am receiving the error on the line that contain
$GLA[$X]+=0;
and ANY other line containing arithmetic ops with that field (and others like it).
Advise please???
Signed: Tired programming grunt