Dear List
I have written the following code .
use Data::Dumper;
%file = (14 = GGG,
11 = AAA,
101 = EEE,
1 = TTT);
print Dumper \%file;
@arr1 = sort { $file{$b} cmp $file{$a} } keys %file; #the oldest entry lies
at the top position
print Dumper
Anirban Adhikary wrote:
Dear List
Hello,
I have written the following code .
use Data::Dumper;
%file = (14 = GGG,
11 = AAA,
101 = EEE,
1 = TTT);
print Dumper \%file;
@arr1 = sort { $file{$b} cmp $file{$a} } keys %file; #the oldest entry lies
at
Dear List
I need to delete each element after every execution of the foreach loop and
I need to update sorted the @arr1 after every execution of the foreach
loop. I have tried a lot but not able to do this Pls
help...
Thanks Regards
Anirban Adhikary
On Mon, Feb 25, 2008
On 02/25/2008 04:32:42 AM, Anirban Adhikary wrote:
- Dear List
-
- I need to delete each element after every execution of the foreach
- loop and
- I need to update sorted the @arr1 after every execution of the
- foreach
- loop. I have tried a lot but not able to do this Pls
-
On Mon, Feb 25, 2008 at 4:32 AM, Anirban Adhikary
[EMAIL PROTECTED] wrote:
Dear List
I need to delete each element after every execution of the foreach loop and
I need to update sorted the @arr1 after every execution of the foreach
loop. I have tried a lot but not able to do this
I cannot get the syntax right for child lookup, Data::Dumper confirms
that I have the structure as I expect (logic may be totally wrong
though). I going to do a webpage pstree command.
foreach my $child (sort keys( $parent{$pid} )) {
dump_process( $child );
}
Type of arg 1 to
/Jerusalem שבת 5 מאי 2007
Subject: hash containing a hash, sorting keys help
I cannot get the syntax right for child lookup, Data::Dumper confirms
that I have the structure as I expect (logic may be totally wrong
though). I going to do a webpage pstree command.
foreach my $child (sort keys( $parent
Ken Foskey wrote:
I cannot get the syntax right for child lookup, Data::Dumper confirms
that I have the structure as I expect (logic may be totally wrong
though). I going to do a webpage pstree command.
foreach my $child (sort keys( $parent{$pid} )) {
dump_process( $child );
}
On 5/5/07, Ken Foskey [EMAIL PROTECTED] wrote:
foreach my $child (sort keys( $parent{$pid} )) {
dump_process( $child );
}
Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi
line 46, near } )
That's saying that you're giving the keys() operator a hash
On Sat, 2007-05-05 at 07:19 -0700, Tom Phoenix wrote:
On 5/5/07, Ken Foskey [EMAIL PROTECTED] wrote:
foreach my $child (sort keys( $parent{$pid} )) {
dump_process( $child );
}
Type of arg 1 to keys must be hash (not hash element) at ./visualise.cgi
line 46, near } )
I have a hash where each key is a first name linked to a last name, any
suggestions on how to loop through the hash to sort the list by the last
names?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
On 12/15/2003 3:17 AM, B. Rothstein wrote:
I have a hash where each key is a first name linked to a last name, any
suggestions on how to loop through the hash to sort the list by the last
names?
Check the Perl FAQ.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
On Mon, 15 Dec 2003 00:17:17 -0800
B. Rothstein [EMAIL PROTECTED] wrote:
I have a hash where each key is a first name linked to a last name, any
suggestions on how to loop through the hash to sort the list by the last
names?
Something like this perhaps?
#!/usr/bin/perl -w
use strict;
my
Can some please help here :)
I have the following
sub dbMonthlySelect() {
my $query;
my $result;
$query = select * from mbstats_se where
STATDATE=TO_DATE('12/30/02','MM/DD/YY');
$result = doQuery($query,'dbMonthlySelect');
my $i =
Try using 'cmp' instead of '=' in your sort. Then it will sort
alphanumerically.
-Original Message-
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 10, 2003 4:43 PM
To: [EMAIL PROTECTED]
Subject: hash sorting
Can some please help here :)
I have the following
and then
print them at the bottom. There should be a way to get sort to do it
correctly but this escapes me at the moment...
http://danconia.org
-Original Message-
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 10, 2003 4:43 PM
To: [EMAIL PROTECTED]
Subject: hash sorting
Ronald Yacketta wrote:
Can some please help here :)
I have the following
sub dbMonthlySelect() {
my $query;
my $result;
$query = select * from mbstats_se where
STATDATE=TO_DATE('12/30/02','MM/DD/YY'); $result =
: Re: hash sorting
Timothy Johnson wrote:
Try using 'cmp' instead of '=' in your sort. Then it will sort
alphanumerically.
This does not appear to help, perldoc perlop says:
Binary cmp returns -1, 0, or 1 depending on whether the left argument
is stringwise less than, equal to, or greater
I think you're missing the intent of the original post. The poster wanted
to know how to sort on the value. Otherwise you're correct.
-Original Message-
From: LRMK
To: Kurtis
Cc: [EMAIL PROTECTED]
Sent: 11/9/02 9:55 AM
Subject: Re: Hash Sorting?
hashes are do not need to be sorted
can access values in that order
eg:-
#first 1 is
$hash{$keylist[0]}
#2 nd
$hash{$keylist[1]}
#n th one
$hash{$keylist}
- Original Message -
From: Kurtis [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, November 07, 2002 5:00 AM
Subject: Hash Sorting?
Hello all
Kurtis wrote:
Hey Timothy,
I couldn't get it to work...I know you can sort on keys, so I went
out
the cheap wayI switched the values with my keys...it's no problem
because my values are unique also
why not just sort on the values?
foreach my $value (sort {$a = $b}
;looksmart.net]
Sent: Thursday, November 07, 2002 4:25 PM
To: [EMAIL PROTECTED]
Subject: Re: Hash Sorting?
Kurtis wrote:
Hey Timothy,
I couldn't get it to work...I know you can sort on keys, so I went
out
the cheap wayI switched the values with my keys...it's no problem
because my
Timothy Johnson wrote:
I guess it depends on whether you want the list of keys sorted by which
has
the highest value or the values themselves. The most common use of this
for me is when I want to sort the keys or values of a hash using a hash
reference, for example if I'm calculating
PROTECTED]
Subject: RE: Hash Sorting?
Timothy Johnson wrote:
I guess it depends on whether you want the list of keys sorted by which
has
the highest value or the values themselves. The most common use of this
for me is when I want to sort the keys or values of a hash using a hash
reference
Hello all..
Does anyone know how to sort a hash in ascending order on the value?
If possible, a little example!
Thanks,
Kurtis
){
do something...
}
which I think is what you want.
-Original Message-
From: Kurtis [mailto:kurtis;asdal.net]
Sent: Wednesday, November 06, 2002 3:01 PM
To: [EMAIL PROTECTED]
Subject: Hash Sorting?
Hello all..
Does anyone know how to sort a hash in ascending order on the value
'; [EMAIL PROTECTED]
Subject: RE: Hash Sorting?
You can use the longer form of sort for this. You may have seen this
before:
my @array = sort {$a cmp $b} @unsorted;
#$a and $b are default variables for the sort command.
#to reverse sort, you can reverse $a and $b.
You can also do this:
foreach(sort
Right you are. sorry.
-Original Message-
From: Perry, Alan [mailto:aperry;loislaw.com]
Sent: Wednesday, November 06, 2002 3:17 PM
To: [EMAIL PROTECTED]
Subject: RE: Hash Sorting?
I think the second example should be:
foreach(sort {$hash{$a} cmp $hash{$b}} keys %hash){
do something
)
{
$value=$hash($key);
#do something..
}
- Original Message -
From: Timothy Johnson [EMAIL PROTECTED]
To: 'Perry, Alan' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, November 06, 2002 6:17 PM
Subject: RE: Hash Sorting?
Right you are. sorry.
-Original Message
29 matches
Mail list logo