Have a look at "hashes of arrays" in perldsc, that gives lots of code examples on how to access data structures like that, and see also perlreftut. For example:
my %database; my $employee_id = 961; my $employee_name = "Anonymous Monk"; my $employee_salary = "fun"; my $employee_ph = 5.5; my @employee_details = ($employee_name,$employee_salary,$employee_ph); $database{$employee_id} = \@employee_details; print "$database{961}[0]: $database{961}[1]\n"; __END__ Anonymous Monk: fun
(Why is "\n" part of the employee's details in your code?)
But then again, this kind of data seems more appropriately stored in a hash of hashes (also described in perldsc):
my %database; my $employee_id = 961; $database{$employee_id} = { name => "Anonymous Monk", salary => "fun", ph=> 5.5 }; print "$database{961}{name}: $database{961}{ph}\n"; __END__ Anonymous Monk: 5.5
In reply to Re: Tring to write script to add and get employee detials to hash
by Anonymous Monk
in thread Tring to write script to add and get employee detials to hash
by yedukondalu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |