Re: list of strings to array
From: Rob Dixon (rob_at_dixon.port995.com)
To: email@example.com Date: Sat, 21 Feb 2004 12:51:43 -0000
David Le Blanc wrote :
> Just a note.
> @array = split / /, "one two three four";
> @array = split " ", "one two three four";
> are not the same. The second is special-cased inside perl to do the
> same as the AWK split command. The first is just a normal regular
> expression matching exactly one space.
> $a=" one two three four "; (note the leading and extra spaces)
> @array = split / /, $a
> @array will contain ( undef, 'one', 'two', undef, 'three', 'four', undef
@array will contain ( '', 'one', 'two', '', 'three', 'four')
'split' returns the next component up to the next separator. If there
are no characters before that separator then the component will be an
empty string. No trailing empty strings are returned.