At 23:48 06/12/2004, you wrote:
On Mon, 6 Dec 2004, Frank Westfield wrote:

> Is there a Perl equivalent of Java String.toArray method?
>
> I need to get an Alpha-Numeric string (16 plus consecutive characters)
> into an array or hash of characters to allow manipulation of the
> individual characters.  The use of substr to extract each characters
> is unweildy.

split ?

What are you ultimately trying to do here ?

Whatever the problem might be, you can probably do it the way you're
setting out on here, but it won't be idiomatic Perl and therefore it
won't play into Perl's best strengths as a string manipulation language.

If you describe what you're really trying to do, rather than just the
mechanism by which you're trying to do it, we might be able to come up
with a cleaner approach than treating the string as an array of chars.

And by "might", I mean "nearly no question whatsoever" :-)

Sorry if what I said was not clear enough.

I have a string of between 16 and 24 consecutive characters - no spaces or other non-alphanumeric characters which split can work on (as I understand split). I need to process each character and reorder the resulting manipulated characters into a new string.

This is an existing perl application which I did not design so unless I redesign the whole thing I cannot change the process. (If I did it would not be in Perl I think) Hence the wording of my original question.

In Java I simply create a String Object and call the toArray method and its all done - a nice array full of characters. I am surprised that Perl with strong manipulation reputation doesn't have similar functionality.


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to