in reply to Fast string construction

You could also use the x operator (repetition):

$bin = "\0" x (4 * ($last_val+1));

A benchmark would have to show whether it's more efficient, though...