There's more than one way to do things | |
PerlMonks |
Re: Why do i get an extra (duplicate) array element?-by graff (Chancellor) |
on Jun 23, 2016 at 18:41 UTC ( [id://1166404]=note: print w/replies, xml ) | Need Help?? |
Based on the last thing you said:
My goal is to somehow stuff all neg values within one array and pos values within another... I would think you want something like this: (There are better regex patterns for matching numeric strings, but the above works in the vast majority of cases.) As for why your script is doing what it does, well, it's hard to say without seeing the actual input data. How about you post your code with data, like this, so we can see what's happening: (Of course, your code and/or data will probably look different -- this is just a demonstration of the idea.) One last point: substr() returns a scalar, not an array; your code is creating an array with a single element on each loop iteration, and that single element is a string of (up to) 17 characters long. The code doesn't make much sense, actually.
In Section
Seekers of Perl Wisdom
|
|