in reply to Re^2: chopping a string into slices - is there a more elegant way to do it?
in thread chopping a string into slices - is there a more elegant way to do it?
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: chopping a string into slices - is there a more elegant way to do it?
by ikegami (Patriarch) on Nov 05, 2008 at 04:07 UTC |