in reply to Sort lists/Data Structures
However, I think you are over complicating things somewhat.
Consider the following:
Does this do what you want?#!/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
Cheers,
Darren :)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sort lists/Data Structures
by mmontemuro (Initiate) on Dec 05, 2008 at 21:19 UTC |