Hi,

I wrote a script to update some websites based on a template system. The script starts 
asking the user to choose a site to update:

[script preamble omitted]

my ($update_path, $site_root, $site_type);

my %choice_hash = (
    1   => 'janeden',
    2   => 'gargnano',
    3   => 'breskens',
);

my %site_hash = (
    janeden => "/Users/jan/Sites/jan-eden",
    gargnano    => "/Users/jan/Sites/gargnano",
    breskens    => "/Users/jan/Sites/breskens",
);

print "\nPlease choose a site!\n\n";

foreach (sort {$a <=> $b} keys %choice_hash) { printf "(%s) %15s\n", $_, 
$choice_hash{$_}; }

print "Choice: ";

chomp (my $site_choice = <STDIN>);

if (exists $choice_hash{$site_choice}) {
    $site_type = $choice_hash{$site_choice};
    $site_root = $site_hash{$site_type}
}
else {
    die "No valid site - scripts exits.\n";
}

While this works, it seems a little clumsy to use two hashes for the choice/sitename 
and sitename/siteroot. I read about hashes of hashes (using references). Could I use 
this method here to simplify my script?

Thanks,

Jan
-- 
The day Microsoft makes something that doesn't suck is the day they start selling 
vacuum cleaners.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to