Welcome to the Monastery | |
PerlMonks |
One liner: split fixed-width field into equal length chunks...by mr. jaggers (Sexton) |
on Mar 21, 2003 at 02:48 UTC ( [id://244788]=perlquestion: print w/replies, xml ) | Need Help?? |
mr. jaggers has asked for the wisdom of the Perl Monks concerning the following question:
Anyone know how to do this? Note, there is no explicit delimiter, I just want k-length chunks from an n-length string (right now, n is a constant defined in the scripts' config module). Anything more elegant than something like...
...would be greatly appreciated. (note: untested... well, probably not well thought out either, but the idea stands) Well, actually, anything shorter and more elegant (I've been told that eval is never elegant ;). BTW, I even know how wide the field is, so I could do a my($d1, $d2, $d3, $d4) = in front of the splitting part. Although the general goal is for an arbitrary length fixed-width field, if I could have the above, get a task done, and I could mark that section for later revision.
Back to
Seekers of Perl Wisdom
|
|