in reply to Comparing and Counting Arrays Length

Perhaps you want:
@array = split ' ', $input{'dummy_a'};

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: Comparing and Counting Arrays Length
by c_lhee (Novice) on Apr 08, 2003 at 09:00 UTC
    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
      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