This problem splits nicely into two parts: getting the data from the database and building the hash of arrays. I'm going to assume that you have (or will) solve the database portion. So here is how to build the hash of arrays:
my %state_hash;
while (<DATA>)
{
chomp;
my ($stamp,$state) = split/\s*\|\s*/;
print "$stamp $state\n";
push @{$state_hash{$stamp}}, $state;
}
print "\n";
for my $stamp (sort keys %state_hash )
{
print "$stamp: @{ $state_hash{$stamp} }\n";
}
__DATA__
200910021546 | Dormant
200910021546 | In Use
200910021352 | In Use
200910021352 | Dormant
200910021352 | In Use
200910021125 | In Use
200910021125 | In Use
200910021125 | Dormant
Which prints:
perl stampstate.pl
200910021546 Dormant
200910021546 In Use
200910021352 In Use
200910021352 Dormant
200910021352 In Use
200910021125 In Use
200910021125 In Use
200910021125 Dormant
200910021125: In Use In Use Dormant
200910021352: In Use Dormant In Use
200910021546: Dormant In Use