Vincent Bufferne wrote:
What's about:
my @foo = ( '1', '2' ,'3' );
my $size = $#foo + 1;
print table size $size\n;
Ouput:
table size 3
print Table size: , scalar(@foo), \n;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
What's about:
my @foo = ( '1', '2' ,'3' );
my $size = $#foo + 1;
print table size $size\n;
Ouput:
table size 3
Vincent
-Original Message-
From: Li Ngok Lam [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 03, 2003 5:14 PM
To: [EMAIL PROTECTED]
Subject: How to measure Array or Hash's
What's about:
my @foo = ( '1', '2' ,'3' );
my $size = $#foo + 1;
you can simplify this by : $size = scalar @foo;
print table size $size\n;
Ouput:
table size 3
TIA, but this is not what I want... because each element is assumpted not in
same length... ie.. I am not going to get the
Li Ngok Lam wrote:
What's about:
my @foo = ( '1', '2' ,'3' );
my $size = $#foo + 1;
you can simplify this by : $size = scalar @foo;
You can simplify even this by : $size = @foo
:)
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
That's not what he was asking.
On Thu, 2003-04-03 at 10:07, BUFFERNE,VINCENT (HP-France,ex1) wrote:
What's about:
my @foo = ( '1', '2' ,'3' );
my $size = $#foo + 1;
print table size $size\n;
Ouput:
table size 3
Vincent
-Original Message-
From: Li Ngok Lam [mailto:[EMAIL
Li Ngok Lam wrote:
My method sounds stupid, but still works :
my @array = ('123', 'abc', 'def', 1..9);
my $len_of_array = 0 ;
foreach my $elem(@array)
{$len_of_array += length($elem) }
print $len_of_array ; # I got '18'
my %hash = (1=2, 2=3, 3=4);
foreach my $key(keys(%hash))
{
Rob Dixon said:
Li Ngok Lam wrote:
My method sounds stupid, but still works :
my @array = ('123', 'abc', 'def', 1..9);
my $len_of_array = 0 ;
foreach my $elem(@array)
{$len_of_array += length($elem) }
print $len_of_array ; # I got '18'
my %hash = (1=2, 2=3, 3=4);
foreach my
Li Ngok Lam wrote:
My method sounds stupid, but still works :
my @array = ('123', 'abc', 'def', 1..9);
my $len_of_array = 0 ;
foreach my $elem(@array)
{$len_of_array += length($elem) }
print $len_of_array ; # I got '18'
my %hash = (1=2, 2=3, 3=4);
foreach my $key(keys(%hash))
I don't know if it is better or faster, but it is shorter. :-)
$ perl -le'
my @array = ( 123, abc, def, 1 .. 9 );
my $len_of_array = do { local $; length @array };
print $len_of_array;
'
18
$ perl -le'
my %hash = ( 1 = 2, 2 = 3, 3 = 4 );
my $len_of_hash = do { local $; length
Li Ngok Lam wrote:
My method sounds stupid, but still works :
my @array = ('123', 'abc', 'def', 1..9);
my $len_of_array = 0 ;
foreach my $elem(@array)
{$len_of_array += length($elem) }
print $len_of_array ; # I got '18'
my %hash = (1=2, 2=3, 3=4);
foreach my $key(keys(%hash))
{
10 matches
Mail list logo