I asked for help earlier in the CB and was pointed to the "References quick reference" page which i think helped me some, but I'm still pretty stuck.
I have a mysql database, for the purposes of this question, we'll say it only has these two columns:
+--------------+---------+
| stamp | state |
+--------------+---------+
| 200910021546 | Dormant |
| 200910021546 | In Use |
| 200910021352 | In Use |
| 200910021352 | Dormant |
| 200910021352 | In Use |
| 200910021125 | In Use |
| 200910021125 | In Use |
| 200910021125 | Dormant |
As you can see, the "stamp" column contains redundant data; what I'm trying to do is create a hash that has unique keys using the "stamp" column and a list for the value using the "state" column, the end result would be something like:
200910021546 = (Dormant,In Use)
200910021352 = (In Use, Dormant, In Use)
200910021125 = (In Use, In Use, Dormant)
I'm using the code below (which isnt correct), but I just can't seem to get my head around the correct way to do this
#!/usr/bin/perl
use DBI;
#use strict;
my $user = "usern";
my $pass = "passw";
my $sql_s = "select stamp,state from pridata order by stamp limit 46";
my $dbh = DBI->connect("dbi:mysql:database=db1;",$user,$pass);
my $sth = $dbh->prepare($sql_s);
$sth->execute();
my $recs = $sth->fetchall_arrayref({});
foreach my $r(@{$recs}){
push(@$r->{stamp}, $r->state);
}
foreach my $l(@{$r->stamp}}){
print $l, "\n";
}
$sth->finish();
$dbh->disconnect();
Stamp is a date/time stamp, in the end all I'm trying to do is get a count for the number of "in use" channels for each unique time stamp, so once I've figured out how to get the data in an array, I'll loop through it and count the number of times "In Use" is found for each unique stamp. If anyone can help me, I'd greatly appreciate it.