unless you mean to work with bytes (encoded characters?)

I don't "mean to work with" anything--ask the OP. I simply sought to enhance ccn's suggestion by pointing out the (..)* template syntax.

And wtf do you think you mean by (encoded characters?). All characters are encoded. It's just a case of how they are encoded. Luckily for me, at least 80% (probably closer to 98%) of the data I deal with, characters == bytes. So, following the 80/20 rule, I only expend effort to deal with the 2% when it is required.

And, as your snippet demonstrates, in order to get strings into perl that are anything other that byte-encoded, the programmer has to take (one or more) extraordinary steps. And if the OP is aware enough of his data to know that s/he needs to take those extraordinary steps, then they are

If the unpack solution does not work for them in their environment, whichever way they become aware of it, it will either be a split second of thought for them to dismiss it as a possibility; or a really, really, good lesson for them to learn.

You seem to believe that you can either:

And that attitude is either:

To summarise: It is impossible to predict the full details of the OPs operating environment, and it will (has!) taken (far more than) 20 questions to interrogate it. So, in a forum such as this, where 20 questions could take anything from 2 days, to 2 weeks, to two times the twelfth of never to ask/be answered; I prefer to grant the OP the assumption of intelligence; rather than assume their stupidity.

Any presumption on your behalf to assume that you can produce code, in response to OPs questions, that will operate perfectly in their environment without their having exercised any modicum of locality awareness or data knowledge, is totally unfounded. And if there is even a 1% percent chance that the code you produce will not operate in their environment without their testing it, then all your efforts and pedantry are wasted; and no better than my "assume the OP knows what they are doing" responses.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: chopping a string into slices - is there a more elegant way to do it? by BrowserUk
in thread chopping a string into slices - is there a more elegant way to do it? by rovf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.