Tom

I thought taking a string and assigning it to an array would do it and I was wrong.

Here is a sample line of source;

"2004-08-03 23:57 1,712,128 GdiPlus.dll" and the recommended split gives me 13 for the number of items. I would like an array that has "2004-08-03", "23:57","1,712,128","GdiPlus.dll" as the elements of the array.

Thanks,
Andrew

At 17:40 2007-11-17, Tom Phoenix wrote:
On 11/16/07, AndrewMcHorney <[EMAIL PROTECTED]> wrote:

> I now got my directory listing into an array of strings. I would like
> to now split up the string into a an array of strings from the
> original string. For example, I might have a string of "a b c d"
> and  I now want a 4 element array containing "a", "b", "c", 'd".
>
> I did the following but it did not work.
>
> @new_dir = @string_array[$index];

What's wrong with it? Was that just some Perl-like code that you typed
at random, or was there some reason to think that it would do what you
want?

> The new_dir array is the string from the string array.
>
> Where did I go wrong?

Do you want split?

  my @pieces = split / /, "a b c d";

I feel that I'm guessing (badly?) at what you want. Am I close? If
you're not trying to break up a string on space, what are you trying
to do?

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.0/1136 - Release Date: 2007-11-17 14:55


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


Reply via email to