my @prizes = [ {
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '500',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '1'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 11:18:01',
'WinnerId' => '2026',
'lineid' => '2026',
'Count' => '1',
'Rate' => 'std'
}];
my %month = ( '01' => 'January',
'02' => 'February',
'03' => 'March',
'04' => 'April',
'05' => 'May',
'06' => 'June',
'07' => 'July',
'08' => 'August',
'09' => 'September',
'10' => 'October',
'11' => 'November',
'12' => 'December',
);
my @mapped_prizes = map +{ $month{(split(/-| /,$_->{'Timestamp'}))[1]} => $_ } , @prizes;
## Which hopefully yields
'November' => [{
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '500',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '1'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 11:18:01',
'WinnerId' => '2026',
'lineid' => '2026',
'Count' => '1',
'Rate' => 'std'},
];
####
######MAPPED PRIZES######
$VAR1 = {
'November' => {
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '500',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '1'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 11:18:01',
'WinnerId' => '2026',
'lineid' => '2026',
'Count' => '1',
'Rate' => 'std'
}
};
$VAR2 = {
'November' => {
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '300',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '100'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 15:06:39',
'WinnerId' => '2027',
'lineid' => '2027',
'Count' => '1',
'Rate' => 'std'
}
};
####
######MAPPED PRIZES######
$VAR1 = 'November';
$VAR2 = {
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '500',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '1'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 11:18:01',
'WinnerId' => '2026',
'lineid' => '2026',
'Count' => '1',
'Rate' => 'std'
};
$VAR3 = 'November';
$VAR4 = {
'GivenAway' => undef,
'Breakdown' => '0',
'Dcode' => '00000',
'UserId' => '8853',
'Prize' => '300',
'Contracts' => [
{
'Year' => undef,
'Make' => undef,
'Model' => undef,
'Contract' => '100'
}
],
'Type' => 'prizes',
'Timestamp' => '2005-11-07 15:06:39',
'WinnerId' => '2027',
'lineid' => '2027',
'Count' => '1',
'Rate' => 'std'
};