Hamish Whittal <[EMAIL PROTECTED]> wrote:
:
: I have a hash that looks like:
:
: { number => {somethings in here} }
:
: Now I need to get at number, not what it references.
my %hash = ( number => {} );
foreach my $key ( keys %hash ) {
# do something with each key ($key)
}
Since your h
On Thursday, June 12, 2003, at 07:30 AM, Hamish Whittal wrote:
I have a hash that looks like:
{ number => {somethings in here} }
Now I need to get at number, not what it references.
If I understand correctly, you're trying to get the lowest number hash
key. That we can do. Try:
my $lowest =
Rob Dixon wrote:
Hamish Whittal wrote:
Ok, thanks Sudarshan, but why did this not work?
pop ( keys (%hash) );
'pop' operates on an array, not a list. This would work
my @keys = keys %hash;
my $key = pop @keys;
I guess you meant shift (@keys), pop will return the last key returned
by
Hamish Whittal wrote:
Ok, thanks Sudarshan, but why did this not work?
pop ( keys (%hash) );
perldoc -f pop
pop works on arrays, keys returns a list (perldoc -f keys)
perldoc -q 'What is the difference between a list and an array?'
Anyways, pop returns the last element of the array not the fir
Hamish Whittal wrote:
> Ok, thanks Sudarshan, but why did this not work?
>
> pop ( keys (%hash) );
'pop' operates on an array, not a list. This would work
my @keys = keys %hash;
my $key = pop @keys;
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail
I have a hash that looks like:
{ number => {somethings in here} }
Now I need to get at number, not what it references.
Tx.
H
On Thu, 2003-06-12 at 14:22, Charles K. Clarkson wrote:
> Hamish Whittal <[EMAIL PROTECTED]> wrote:
> :
> : I have a hash and want to return the first key in
> : the hash
Ok, thanks Sudarshan, but why did this not work?
pop ( keys (%hash) );
Thanks.
H
On Thu, 2003-06-12 at 14:39, Sudarshan Raghavan wrote:
> Hamish Whittal wrote:
>
> >Hi all,
> >
> >I have a hash and want to return the first key in the hash. How can I do
> >this?
> >
>
> The answer is (keys (%yo
Hamish Whittal <[EMAIL PROTECTED]> wrote:
:
: I have a hash and want to return the first key in
: the hash. How can I do this?
You can't. The keys of a hash are unordered.
there is no first key (or second key, or lastkey,
etc.) To get a "first key", you'll have to define
what a "first key" is
darshan Raghavan[SMTP:[EMAIL PROTECTED]
> Sent: Thursday, June 12, 2003 6:09 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Returning the first key in a hash...
>
>
>
> Hamish Whittal wrote:
>
> >Hi all,
> >
> >I have a hash and want to return t
Hamish Whittal wrote:
Hi all,
I have a hash and want to return the first key in the hash. How can I do
this?
The answer is (keys (%your_hash))[0]. This will return the first element
in the list of hash keys returned by keys. But, you can never be sure of
the order in which the keys will be re
Hi all,
I have a hash and want to return the first key in the hash. How can I do
this?
Thanks in advance,
Hamish
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
11 matches
Mail list logo