in reply to goto HACK
I need some help figuring out the right way with an arrayYour instinct is correct, and a hash of arrays (HoA) is the "best" way to go about this:
Since all of your data items were identical, I also added $ord to show that they do indeed preserve their order.#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my @times = qw(1000 1000 1000 1010 1010 1010); my $hash = {}; my $ord; for my $time (@times) { my $event = { one => 1, two => 2, ord => $ord++ }; push @{$hash->{$time}}, $event; } print Dumper $hash;
|
|---|