go ahead... be a heretic | |
PerlMonks |
Re: Align string on a 32-bit boundary with paddingby johngg (Canon) |
on Aug 18, 2022 at 09:51 UTC ( [id://11146219]=note: print w/replies, xml ) | Need Help?? |
Use pack with the Z template. Update: An example.
Update 2: Don't use this, if the string is already aligned to a 32-bit boundary the Z template will overwrite the last character with a NULL is it seems to always produce a C-style NULL-terminated string. Update 3: Removed the strike-through! The solution is to only pad with pack when necessary but it does begin to look messy.
Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|