in reply to •Re: Comparing and Counting Arrays Length
in thread Comparing and Counting Arrays Length

it worked.. why do i have to include this statement --split ' ', ---what does this do.
@array1 = split ' ', $input{'dummy_a'}; $array_lenth = @array = (@array1);
c_lhee@yahoo.com

Replies are listed 'Best First'.
Re: Comparing and Counting Arrays Length
by Abigail-II (Bishop) on Apr 08, 2003 at 09:09 UTC
    If you do:
    @array1 = "foo bar baz";

    Then you have just one thing on the right hand side. Hence, you only get one thing on the left hand side, so @array1 contains just one element.

    The split function, as documented in the manual page, takes a regex and a string as argument, and splits the string in several parts, based on the regex. An argument of " " is special, and splits the string on whitespace. Splitting "foo bar baz" on whitespace gives you a list of three strings, hence the array will contain three elements.

    Abigail