Hi All,

I hope I am not wasting anyones time here, as I seem
to have arrived at a solution. I just want to make
sure that my code is really doing what I want it to,
or simplying appearing to.

I am building a database of illustrations into a hash
of arrays, keyed by name. The basic structure is as
follows:

%database = (
name => [ extension, date, filters, description, other
stuff]
)

The script will recieve an array which contains a list
of some of the keys from this hash. This array must
then be sorted based on the date element of the
database (i.e. $database{name}[1] ). I have tried the
following code (with made up stuff in it), and it
seems to work, but it just seems a bit too easy. I get
suspicious when I hit the answer first time. =8O)

#!/usr/local/bin/perl -w

use strict;

my %database = (
                                vivian          => ["gif", "24"],
                                mai                     => ["gif", "19"],
                                kelly           => ["jpeg", "21"],
                                natalie         => ["png", "18"],
                                jennifer        => ["avi", "24"],
                                sarah           => ["gif", "23"],
                                louise          => ["jpeg", "22"],
                                cameron         => ["jpeg", "27"],
                                );

my @sample = ("vivian", "kelly", "jennifer", "sarah",
"louise",);

foreach (sort { $database{$a}[1] <=> $database{$b}[1]
} @sample) {
        print "$_: $database{$_}[1]\n";
}

Thank you for your patience.

Best regards,

Richard
--
Illustrator/Designer

http://www.team-artonomy.com

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music 
Charts
http://uk.my.yahoo.com

Reply via email to