I'm going on the assumption that you don't want the keys to be assigned to a list, but rather you want the hash values for a particular month to be assigned to the list. I haven't bothered sorting the result as you can sort the list however you want once it is assigned.
#!/usr/bin/perl
use warnings;
use strict;
my %ManagerInCharge = (
200610 => {
1 => "jane",
2 => "john",
3 => "joe",
4 => "frank",
},
200701 => {
1 => "gunder",
2 => "abel",
3 => "frank",
}, );
my $month = "200701";
#
# If you need the keys assigned, then the statement
# my @slice = keys %{$ManagerInCharge{$month}}
# is enough.
#
my @slice = map { $ManagerInCharge{$month}{$_} }
( keys %{$ManagerInCharge{$month}} );
for (@slice) {
print "value is $_\n";
}
and the results are:
C:\Code>perl assign_slice.pl
value is gunder
value is frank
value is abel
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.