in reply to Source Grabber

You wrote my $length=length(@list); and this is completely wrong. You should have written my $length = @list; instead. Here's what you got: length() puts its argument in scalar context and evaluates it as a string. An array in scalar context returns the number of elements it contains. A number that's used like a string is converted to a string. length() returns the number of characters in its string. So if you had ten elements in the list, you were doing the equivalent of length("10") which is 2.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: Source Grabber
by Andrew_Levenson (Hermit) on Mar 30, 2006 at 02:30 UTC
    That was it. I changed exactly what you said and it works perfectly now.
    Thanks tons.
Re^2: Source Grabber
by parv (Parson) on Mar 31, 2006 at 06:46 UTC

    BTW, the corresonding function to C<length()> is <scalar()> for a list (which forces scalar context, as already stated above).

    In case not already clear, this was meant for Andrew_Levenson.

      scalar() for a list

      No. scalar() imposes scalar context for whatever expression is its argument regardless of whether that expression is a list, array, scalar, function call, etc.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      A reply falls below the community's threshold of quality. You may see it by logging in.