in reply to Re: How do I find the size of an array?
in thread How do I find the size of an array?

What's wrong with:

$length = @array;

For example:

#!/usr/bin/perl use strict; my @array = qw(one two three); my $length = $#array + 1; print "Dollar pound array = $length\n"; $length = @array; print "At symbol array = $length\n"; __DATA__ {C} > test.pl Dollar pound array = 3 At symbol array = 3

Replies are listed 'Best First'.
Re^2: Answer: How do I find the size of an array?
by merlyn (Sage) on Feb 10, 2010 at 00:53 UTC
    What's wrong with:
    $length = @array;
    Nothing. TIMTOWTDI.

    -- Randal L. Schwartz, Perl hacker

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.