Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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??
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pack/unpack left padding
by moritz (Cardinal) on Sep 10, 2007 at 18:52 UTC | |
|
Re: pack/unpack left padding
by ikegami (Patriarch) on Sep 10, 2007 at 19:13 UTC | |
|
Re: pack/unpack left padding
by Skeeve (Parson) on Sep 10, 2007 at 18:52 UTC |