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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.