in reply to Rogue Null (ordinate 0) characters in text files

I would just use a regular expression:
if ($line =~ m/([\0-\x8\xb-\x1f\x7e-\xff])/) { print "$line contains illegal character (ord: ", ord($1), ")\n"; }
The reason why your code isn't working is because instead of:
@character=split /\.*/; while (@character){
you really want:
@character=split //; # split $_ into single characters while (@character){
With the original split call, when there's a dot at the beginning of the line the first element of @character is the empty string.

Replies are listed 'Best First'.
Re^2: Rogue Null (ordinate 0) characters in text files
by paulnovl (Novice) on May 08, 2008 at 07:18 UTC
    Thanks to you all for those very useful replies.

    You've taught me a lot.