in reply to Printing the length of an array ?
#! /usr/bin/perl use strict; use warnings; my @array = qw/1 2 3 4 5 6 7/; print "number of elements is " . ++$#array . "\n";
The increment is necessary because the first element is @array[0].
This produces:
ww@GIG:~/pl_test$ perl elementsinarray.pl number of elements is 7
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing the length of an array ?
by FunkyMonk (Bishop) on Mar 30, 2008 at 21:21 UTC | |
by ww (Archbishop) on Mar 30, 2008 at 21:30 UTC | |
by chromatic (Archbishop) on Mar 30, 2008 at 21:57 UTC | |
by shmem (Chancellor) on Mar 30, 2008 at 22:08 UTC | |
by Not_a_Number (Prior) on Mar 30, 2008 at 22:38 UTC | |
by wardy3 (Scribe) on Mar 31, 2008 at 04:39 UTC |