Re: [OT] Help with Perl Script
- From: Norman Gaywood <ngaywood@xxxxxxxxxx>
- Date: Thu, 22 Apr 2010 01:26:04 +1000
On Wed, Apr 21, 2010 at 04:12:06PM +0100, Dan Track wrote:
On Wed, Apr 21, 2010 at 1:30 PM, Norman Gaywood <ngaywood@xxxxxxxxxx> wrote:
On Wed, Apr 21, 2010 at 09:21:30AM +0100, Dan Track wrote:
hashes. It's after this that I'm stuck, I'm struggling to order the[snip]
hash of hashes by uid and then print the ordered list out? Can someone
foreach my $sorted ( sort { $HoH->{$a}{uid} cmp $HoH->{$b}{uid} } keys %HoH)
cmp is a string comparison. You probably want to sort numerically on the
uid. So replace 'cmp' with '<=>'
foreach my $sorted ( sort { $HoH{$a}->{"uid"} <=> $HoH{$b}->{"uid"} } keys %HoH)
{
print STDOUT "$HoH{$sorted}\n"
}
and all I get out is:[snip]
perl sort.pl
HASH(0x89de3d0)
HASH(0x8a05d40)
$HoH{$sorted} is a reference to a hash. $HoH{$a}{uid} (or in
long hand $HoH{$a}->{"uid"}) should print out the uid numbers.
--
Norman Gaywood, Computer Systems Officer
University of New England, Armidale, NSW 2351, Australia
ngaywood@xxxxxxxxxx Phone: +61 (0)2 6773 3337
http://mcs.une.edu.au/~norm Fax: +61 (0)2 6773 3312
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
- Follow-Ups:
- Re: [OT] Help with Perl Script
- From: Norman Gaywood
- Re: [OT] Help with Perl Script
- References:
- [OT] Help with Perl Script
- From: Dan Track
- Re: [OT] Help with Perl Script
- From: Norman Gaywood
- Re: [OT] Help with Perl Script
- From: Dan Track
- [OT] Help with Perl Script
- Prev by Date: Re: [OT] Help with Perl Script
- Next by Date: Re: Breakin attempts
- Previous by thread: Re: [OT] Help with Perl Script
- Next by thread: Re: [OT] Help with Perl Script
- Index(es):
Relevant Pages
|