This is line is causing it: substr($FirstLine, -1, 1) = $DataLine. As someone already mentioned, you should really just use the regex on the returned value from substr() (Perl is magic like that). Or, you could do $FirstLine .= $DataLine to append one string to the end of another.
Jeff japhy Pinyan,
P.L., P.M., P.O.D, X.S.:
Perl,
regex,
and perlhacker How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart