John W. Krahn wrote: > Keenan, Greg John (Greg)** CTR ** wrote: >> >>my $cfgDir = '/amanda/admin/etc/amanda'; >>my @cfgs = qw(Toaster MFG-UNIX SYS-UNIX Amanda-Daily); >>my %numTapes = ( >> "$cfgs[0]" => 6, >> "$cfgs[1]" => 5, >> "$cfgs[2]" => 5, >> "$cfgs[3]" => 1, >> ); > > Do you really need an array and a hash? If you need keep the order of @cfgs > you could use an array of arrays: > > my @cfgs = ( > [ Toaster => 6 ], > [ MFG-UNIX => 5 ], > [ SYS-UNIX => 5 ], > [ Amanda-Daily => 1 ], > ); > > If you don't really care about the order then just use a hash: > > my %cfgs = ( > Toaster => 6, > MFG-UNIX => 5, > SYS-UNIX => 5, > Amanda-Daily => 1, > );
Small correction: because of the hyphens those barewords need to be quoted. my @cfgs = ( [ Toaster => 6 ], [ 'MFG-UNIX' => 5 ], [ 'SYS-UNIX' => 5 ], [ 'Amanda-Daily' => 1 ], ); my %cfgs = ( Toaster => 6, 'MFG-UNIX' => 5, 'SYS-UNIX' => 5, 'Amanda-Daily' => 1, ); :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>