Re: The last element

2005-05-08 Thread Paul D. Kraus
> How can I call the last element in the array? use strict; use warnings; my @array = qw/ one two three /; print $#array . "\n"; print $array[$#array] . "\n"; $#array gives you the last element. So my array has three elements but counting starts at zero. so my last ele

Re: The last element

2005-05-07 Thread Offer Kaye
On 5/8/05, amr wrote: > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? > if the array is called "@array", the last element can be called either using: $array[$#array] or $array[-1] Read: h

Re: The last element

2005-05-07 Thread Gavin Henry
On Saturday 07 May 2005 23:05, Peter Rabbitson wrote: > On Sat, May 07, 2005 at 04:13:12PM -0700, amr wrote: > > How can I call the last element in the array? > > > > I try the pop and it does the job but I think there is another way? > > If > my @a = (1, 2, 3,

Re: The last element

2005-05-07 Thread Peter Rabbitson
On Sat, May 07, 2005 at 04:13:12PM -0700, amr wrote: > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? > If my @a = (1, 2, 3, 4); then: my $last = pop @a; is the same as my $last = $

RE: The last element

2005-05-07 Thread Charles K. Clarkson
Ricardo SIGNES wrote: : * amr <[EMAIL PROTECTED]> [2005-05-07T19:45:56] : : Thanks it was very useful. : : Now, I need to do the same with sorted hash array. Can I? : : "sorted hash array" is not clear, to me. Do you mean you've done : this: sort keys %hash : ? :

Re: The last element

2005-05-07 Thread Gavin Henry
On Saturday 07 May 2005 20:56, John W. Krahn wrote: > Gavin Henry wrote: > > On Sunday 08 May 2005 00:13, amr wrote: > >>How can I call the last element in the array? > >> > >>I try the pop and it does the job but I think there is another way? > > >

Re: The last element

2005-05-07 Thread John W. Krahn
Gavin Henry wrote: On Sunday 08 May 2005 00:13, amr wrote: How can I call the last element in the array? I try the pop and it does the job but I think there is another way? Of course, TMTOWTDI (http://catb.org/~esr/jargon/html/T/TMTOWTDI.html) $ARRAY[$#ARRAY--] Oh wow. Did you try that? You do

Re: The last element

2005-05-07 Thread Gavin Henry
On Sunday 08 May 2005 00:13, amr wrote: > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? Of course, TMTOWTDI (http://catb.org/~esr/jargon/html/T/TMTOWTDI.html) $ARRAY[$#ARRAY--] See: http://perldoc.perl.org/

Re: The last element

2005-05-07 Thread Ing. Branislav Gerzo
amr [a], on Saturday, May 7, 2005 at 16:45 (-0700) typed the following: a> Now, I need to do the same with sorted hash array. Can I? you can do everything. But give us example of source data dump. -- ...m8s, cu l8r, Brano. [Home: A place teenagers stay while the car is repaired.] -- To u

Re: The last element

2005-05-07 Thread bright true
$array[-1] On 5/7/05, amr <[EMAIL PROTECTED]> wrote: > > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? > >

Re: The last element

2005-05-07 Thread Ricardo SIGNES
* amr <[EMAIL PROTECTED]> [2005-05-07T19:45:56] > Thanks it was very useful. > Now, I need to do the same with sorted hash array. Can I? "sorted hash array" is not clear, to me. Do you mean you've done this: sort keys %hash ? If so, just reverse the sort and use the first element, or ass

RE: The last element

2005-05-07 Thread amr
Thanks it was very useful. Now, I need to do the same with sorted hash array. Can I? Thanks Amr -Original Message- From: Ing. Branislav Gerzo [mailto:[EMAIL PROTECTED] Sent: Saturday, May 07, 2005 6:16 AM To: beginners@perl.org Subject: Re: The last element amr [a], on

Re: The last element

2005-05-07 Thread Ramprasad A Padmanabhan
On Sun, 2005-05-08 at 04:43, amr wrote: > How can I call the last element in the array? > > I try the pop and it does the job but I think there is another way? > > > $array[-1] HTH Ram -- Netcore Solutions Pvt. L

Re: The last element

2005-05-07 Thread Ing. Branislav Gerzo
amr [a], on Saturday, May 7, 2005 at 16:13 (-0700) thinks about: a> I try the pop and it does the job but I think there is another way? here are some examples comes to my mind: use strict; use warnings; my @list = 1 .. 10; print $list[-1], "\n"; print $list[$#list], "\n"; print [EMAIL PROTECTE

The last element

2005-05-07 Thread amr
How can I call the last element in the array? I try the pop and it does the job but I think there is another way?

Re: hash of ref to array of arrays, lost all but the last element in hash

2001-08-24 Thread Kelvin Teh
d like to construct a hash, whose value holds a reference to an > array of arrays, > however all the keys in my hash have the exact same value, which turns > out to be the value of the last element I put it!! > > I felt that something is wrong in the data structure, that I should not &

RE: hash of ref to array of arrays, lost all but the last element in hash

2001-08-23 Thread Bob Showalter
> -Original Message- > From: Jennifer Pan [mailto:[EMAIL PROTECTED]] > Sent: Thursday, August 23, 2001 1:05 PM > To: [EMAIL PROTECTED] > Cc: Maxim Berlin > Subject: hash of ref to array of arrays, lost all but the last element > in hash > > > Dear all, &g

hash of ref to array of arrays, lost all but the last element in hash

2001-08-23 Thread Jennifer Pan
Dear all, I would like to construct a hash, whose value holds a reference to an array of arrays, however all the keys in my hash have the exact same value, which turns out to be the value of the last element I put it!! I felt that something is wrong in the data structure, that I should not