Dereference a HASH reference

Mark Haney <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.general
Message-ID <[email protected]>
I'm at my wits end.  I've pulled every trick I know (which ain't many) 
and I still can't get this working.  Please, for the love of pete (and 
my sanity) help with this.

I'm building a web page that has a series of checkboxes each with a day 
of the week.  Pretty straightforward, right?  Well, from that page I'm 
passing the params to a CGI script that does this:

> my %attrs = (
> 	shift_name => $q->param('shift_name'),
> 	shift_beg => $q->param('shift_beg'),
> 	shift_end => $q->param('shift_end'),
> 	shift_days => $q->param('dow'),
> 	factory_id => $q->param('factory'),
> );

 From there I pass a reference to the hash to a subroutine 
($dao->insert_shift(\%attrs);

Here's where it blows up.  This is the sub:

sub insert_shift {
       my $self = shift;
       my($attrs) = @_;

       my $m = $self->schema->resultset('Shifts')->new($attrs);
       $m->insert;
}

 From here it gets inserted into a DB table (called shifts, obviously).

Here's my problem, with the original %attrs I was getting the 'dow' 
params but the insert into the DB bombs because the param('dow') isn't a 
scalar(?).  I did have someone tell me that I needed the line:

shift_days => $q->param('dow'),

to be:

shift_days => [ $q->param('dow') ],

At that point I get all the data inserted into the database EXCEPT the 
DOW (day of week) parameter, which I only get this: ARRAY(0x9517d38)

This is where I'm stuck.  I know I need to dereference that hash, but 
for the life of me I can't figure it out.

Early on, when I realized that the 'dow' was being passed as an array I 
tried to convert that array into a string, but it never did work. At 
least i couldn't make it work.

Does anyone have some idea on what I should do next?  At this point, 
I'll try anything short of shooting my dog.

Help.


-- 

Mark Haney
Software Developer/Consultant
AB Emblem
[email protected]
Linux marius.homelinux 3.3.8-1.fc16.x86_64 GNU/Linux
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.