Matthew Whipple schreef:
> If you're looking for the last element then you could
> use $files[$#files]
Or $files[-1].
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
I use the scalar keyword on occasion:
#!/usr/bin/perl
my @arr = qw/adfs adsf 4fd feqw3 f432d/;
print "The size of the array is " . scalar (@arr) . "\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Matthew Whipple wrote:
> yitzle wrote:
>
>> What are you trying to accomplish?
>> What is @files? Did you define it somewhere? Or is it a Perl global
>> var I don't know of?
>>
>>
>>
> The below is speculation since these questions need to be answered. In
> addition to what is @files I'
m: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle
> Sent: October-19-07 11:16 AM
> To: Joseph L. Casale
> Cc: beginners@perl.org
> Subject: Re: Printing size of array unitializes array?
>
> What are you trying to accomplish?
> What is @files? Did you define it som
yitzle wrote:
> What are you trying to accomplish?
> What is @files? Did you define it somewhere? Or is it a Perl global
> var I don't know of?
>
>
The below is speculation since these questions need to be answered. In
addition to what is @files I'd add what is $Tmp?
> On 10/19/07, Joseph L. Ca
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
> open (FILEOUT, "> $OutDir/info") or die $!;
> print FILEOUT "text = abc\n";
> my $Tmp = ++$#files;
Huh?
> print FILEOUT "moretext = $Tmp\n";
> When I add the 3rd line, it initializes the fi
Sorry, it is an array I used above this block of code.
jlc
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yitzle
Sent: October-19-07 11:16 AM
To: Joseph L. Casale
Cc: beginners@perl.org
Subject: Re: Printing size of array unitializes array?
What are you
What are you trying to accomplish?
What is @files? Did you define it somewhere? Or is it a Perl global
var I don't know of?
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote:
> I had the following code:
>
> open (FILEOUT, "> $OutDir/info") or die $!;
> print FILEOUT "text =
I had the following code:
open (FILEOUT, "> $OutDir/info") or die $!;
print FILEOUT "text = abc\n";
my $Tmp = ++$#files;
print FILEOUT "moretext = $Tmp\n";
When I add the 3rd line, it initializes the files array and I can't use it
after? Why is that
I guess you could always dereference the array then find its size.
my(@sample, $ref, @de_ref);
# Original array.
@sample = ('sample', 'sample');
# Make reference to original array.
$ref = [EMAIL PROTECTED];
# De-reference the original array.
@de_ref = @$ref;
# Get the size from the reference.
pri
Andrew Gaffney wrote:
> david wrote:
> > Andrew Gaffney wrote:
> >
> >
> >>I've got an array reference and I'm trying to figure out how many elements
> >>are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and
> >>probably a few others that I've forgotten. What is the corre
Andrew Gaffney wrote:
>
> david wrote:
> > Andrew Gaffney wrote:
> >
> >
> >>I've got an array reference and I'm trying to figure out how many elements
> >>are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and
> >>probably a few others that I've forgotten. What is the corr
david wrote:
Andrew Gaffney wrote:
I've got an array reference and I'm trying to figure out how many elements
are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and
probably a few others that I've forgotten. What is the correct way to do
this?
you can try @{EXP} or $#{E
Andrew Gaffney wrote:
> I've got an array reference and I'm trying to figure out how many elements
> are in it. I've tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and
> probably a few others that I've forgotten. What is the correct way to do
> this?
you can try @{EXP} or $#{EXP}+1 w
I've got an array reference and I'm trying to figure out how many elements are in it. I've
tried '$#arrayref', '[EMAIL PROTECTED]', '$(@($arrayref))', and probably a few others that I've
forgotten. What is the correct way to do this?
--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, L
rraysize elements\n";
my $arraysize = @{$array[1]};
print "Second sub array size is $arraysize elements\n";
HTH
John
-Original Message-
From: Agustin Rivera [mailto:[EMAIL PROTECTED]]
Sent: 18 February 2002 17:18
To: [EMAIL PROTECTED]
Subject: Size of Array
Thank-you to everyo
On Mon, Feb 18, 2002 at 09:17:50AM -0800, Agustin wrote:
> Quick one.. is there a way to evaluate the size of an array? Right now I'm
> writing the arrays to a file and then doing an "ls -l" to compare sizes. The
> array is of type $array[0][0] and not $array[0] (if anyone has the proper
> termin
Thank-you to everyone who answered my last question. As usually I am very
grateful for this group and the people in it.
Quick one.. is there a way to evaluate the size of an array? Right now I'm
writing the arrays to a file and then doing an "ls -l" to compare sizes. The
array is of type $array
18 matches
Mail list logo