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...
for(my($i)=0;$i<$length-2;$i+=$n)
{
eval{"\$d".($i-1/$n)} = substr($field, $i, $i+2)
}
...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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.