Dereference a HASH reference
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 ma...@abemblem.com Linux marius.homelinux 3.3.8-1.fc16.x86_64 GNU/Linux
Dereference a HASH reference - SOLVED
Hmm, maybe talking it out (so to speak) helped. I found a way of (or the proper syntax to) allow me to JOIN the day of week array into a string which fixes the problem of the hash. I'm not sure why the join works now and not a week ago, but at this point I don't care. -- Mark Haney Software Developer/Consultant AB Emblem ma...@abemblem.com Linux marius.homelinux 3.3.8-1.fc16.x86_64 GNU/Linux
DBD::ODBC and ODBC SQL Servre driver
Hi, I am currently using the trial version of the Easysoft ODBC-SQL Server driver. I need to be able to connect from Perl to SQL Server using a Linux machine and am currently using DBI version 1.607. I was hoping someone could tell me which versions of the DBD::ODBC and ODBC-SQL Server driver would be compatible with this version of the DBI so that I would not have to update the DBI
Fwd: Re: DBD::ODBC and ODBC SQL Servre driver
Oops, forgot to post this to the list. Martin ---BeginMessage--- On 18/06/2012 21:51, Shrenuj Bansal wrote: Hi, I am currently using the trial version of the Easysoft ODBC-SQL Server driver. I need to be able to connect from Perl to SQL Server using a Linux machine and am currently using DBI version 1.607. I was hoping someone could tell me which versions of the DBD::ODBC and ODBC-SQL Server driver would be compatible with this version of the DBI so that I would not have to update the DBI You should be fine with 1.607. You don't mention the DBD::ODBC version - recent versions have fixed some bugs but mostly they have been enhancements. If you have got a trial of the ODBC SQL Server Driver you should have a recent version but if you have any issues with it contacting supp...@easysoft.com is probably more appropriate than posting here. Martin ---End Message---
Re: Re: DBD::ODBC and ODBC SQL Servre driver
On Monday, June 18, 2012 3:54:45 PM UTC-6, quot;Martin J. Evansquot; wrote: Oops, forgot to post this to the list. Martin Well, whenever I run the example script given to connect to the SQL Server DB, the compiler gives me an error on the use DBI line saying that that current system is not using the right DBI version. I wasn't sure if that was because the DBD or the ODBC driver wasn't compatible with v1.607 and the description on the website for both these modules does not really state which DBI is needed. I was using DBD-ODBC-1.33 and odbc-sqlserver-1.4.27 for the ODBC driver.
Re: DBD::ODBC and ODBC SQL Servre driver
On 18/06/2012 23:23, Shrenuj Bansal wrote: On Monday, June 18, 2012 3:54:45 PM UTC-6,quot;Martin J. Evansquot; wrote: Oops, forgot to post this to the list. Martin Well, whenever I run the example script given to connect to the SQL Server DB, the compiler gives me an error on the use DBI line saying that that current system is not using the right DBI version. I wasn't sure if that was because the DBD or the ODBC driver wasn't compatible with v1.607 and the description on the website for both these modules does not really state which DBI is needed. I was using DBD-ODBC-1.33 and odbc-sqlserver-1.4.27 for the ODBC driver. Can we see the error you get? Martin
Re: Dereference a HASH reference
this is entirely off-topic for dbi-users. That said, what you're seeing is due to $q-param('dow') called in array context returning some number of things other than one thing. There are various ways to fix it, depending on how $q works. The approach you tried, putting one of the param lookups inside an anon arrayref constructor, is halfway there -- you need to reach into that array later when you use it. The situation is also a subtle security flaw, as a user can in theory construct funny form data with multiple entries for names and overwrite for instance shift_beg by giving three 'factory' data, the middle one being 'shift_beg. Wrapping one of them in square brackets doesn't help with the general exploit. 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'), ); This: my %attrs = ( shift_name = scalar($q-param('shift_name')), shift_beg = scalar($q-param('shift_beg')), shift_end = scalar($q-param('shift_end')), shift_days = scalar( $q-param('dow')), factory_id = scalar( $q-param('factory')), ); will always give you exactly one thing in the value slots, then depending on what you see there you can adjust. -- [Feynman]'s wife was granted a divorce from him because of [his] constantly working calculus problems in his head as soon as awake, while driving car, sitting in living room, and so forth, and that his one hobby was playing his African drums. His ex-wife reportedly testified that on several occasions when she unwittingly disturbed either his calculus or his drums he flew into a violent rage, during which time he choked her, threw pieces of bric-a-brac about and smashed the furniture. -- FBI