I have fixed-width data file where numbers are padded on the left. I want to be able to use unpack to extract these number, but unpack wants the data to the right-padded. What can I do?
print '>' . unpack('A6','123 ') . "<\n"; # prints >123< print '>' . unpack('A6',' 123') . "<\n"; # prints > 123< <---- extra leading space??
In reply to pack/unpack left padding by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |