in reply to Null-stripping performance
Another thought that would probably be more efficient, if all your null padded fields are numeric.
Perl quite happily interprets strings that contain digits and leading or trailing spaces as numbers without requiring the spaces to be removed first. If you simply replace all the nulls with spaces in a single operation:
$str =~ tr[\0][ ];
From that point on you can just use substr:
sub fetchOne{ substr $str, $_[ 0 ] * 4, 4 }
|
|---|