in reply to Sort lists/Data Structures

What you are looking for is the sort function.

However, I think you are over complicating things somewhat.
Consider the following:

#!/usr/bin/perl use strict; use warnings; my %people; while (my $line = <DATA>) { chomp($line); my ($person, $occupation, $hours) = split /\s+/, $line; $people{$person}{occupation} = $occupation; $people{$person}{hours} = $hours; } for my $person (sort keys %people) { print "Name: $person\n"; print "Job: $people{$person}{occupation}\n"; print "Hours: $people{$person}{hours}\n"; print "------------------\n"; } __DATA__ Mike Plumber 80 Laura Programmer 60 Mark Sales 70 Jeremy Cook 65
Does this do what you want?

Darren :)

Replies are listed 'Best First'.
Re^2: Sort lists/Data Structures
by mmontemuro (Initiate) on Dec 05, 2008 at 21:19 UTC
    For a few elements, I agree with what you have. My actual program has about 60+ elements. It gets a bunch of fields from a database. So in this case, I felt that a data structure returning a reference is easier to work with. So your previous solution works just fine to display these records. Thanks again for your speedy response.