Your first line contains the * character. You use the data itself as a regular expression when you try to delete the line, but at that point the asterix is interpreted as a regexp metacharacter. The data does not match /....marks_pabs * 4211..../, because that essentially means ".....marks_pabs, one or more spaces, then 4211". (1)
Why are you using a regular expression s/// at all to delete the line? You already know exactly what you want to put there, and you want to override the whole $element. So simply assign an empty string.
From a broader view, though, you shouldn't be slurping the whole file to @ARRAY. That's not scalable. You can read the file line by line and write to a temporary file, eventually copying that over to the original. Or, if you want to edit in-place, check out Tie::File.
(1) Update: to clarify, an asterix means just *zero* or more times, but / * / means zero or more spaces, then another space.
In reply to Re: bewildering array element problem
by gaal
in thread bewildering array element problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |