To be clear: moritz was talking about "removing all initial non-whitespace characters", and saying that it would be "not so safe" to do that -- and he would be right, in the sense that sometimes, initial non-whitespace characters might not be garbage, and it would be bad to remove them.
GrandFather has proposed a different approach: just remove null bytes. There is nothing "unsafe" about this -- null bytes carry no relevant information, and they just get in the way. Deleting null bytes from your strings is a Good Thing.
| [reply] |
What moritz suggested was stripping any non-whitespace characters. The regex I suggested just removes leading ASCII null characters. For the task at hand that should be completely safe.
I strongly recommend that you learn about Perl regular expressions. See perlretut, perlre and perlreref. A browse around the Tutorials section here is likely to pay off too.
DWIM is Perl's answer to Gödel
| [reply] |