Zaxo has pointed you in the right direction, but
if for any means, if you need 'modular sugar',you can use something like this with better design.
package Hash;
sub new {
my $class = shift;
my $self = {};
bless $self,$class;
}
sub addKey {
my $self = shift;
my $key = shift;
$self->{$key};
}
sub printKeys {
my $self = shift;
foreach (keys %{$self}){
print "$_\n";
}
}
sub addValues {
my $self = shift;
my $key = shift;
push @{$self->{$key}}, @_;
}
sub printValues {
my $self = shift;
my $key = shift;
print "$key\t";
foreach (@{$self->{$key}}){
print "$_\t";
}
print "\n";
}
package main;
my $hash = new Hash;
$hash->addKey('fruit');
$hash->addValues('fruit', 'apple');
$hash->addValues('fruit','orange');
$hash->printValues('fruit');
$hash->addKey('operating system');
$hash->addValues('operating system', 'Linux','Windows XP');
$hash->printValues('operating system');
artist |