[Dbix-class] DBIx::Class::Resultset - DBI Exception near PATH

Ronald J Kimball rkimball+dbixclass at pangeamedia.com
Wed Feb 18 22:36:49 GMT 2009


onken at houseofdesign.de wrote:
> $hashref->{'users_reference'} does nox exist. I had problems with undef
> variables in a hash. I generally put a "scalar" in front of my variables,
> this fixes the "undef value in hash"-problem
> 
> 
> e.g.
> 
> ->find_or_create({
> ...
> users_reference  => scalar $hashref->{'users_reference'},
> ...
> });


There is no difference between

   {
     users_reference  => $hashref->{'users_reference'},
   }

and

   {
     users_reference  => scalar $hashref->{'users_reference'},
   }


$hashref->{'users_reference'} is already a scalar.  Either way, you will 
get the value of $hashref->{'users_reference'}, or undef if the key 
doesn't exist.


You're confusing this case with calling a subroutine that could return 
an empty list:

   {
     users_reference  => $cgi->param('users_reference'),
   }

versus

   {
     users_reference  => scalar $cgi->param('users_reference'),
   }

The former snippet will not do the right thing if 
$cgi->param('users_reference') returns zero values or more than one 
value.  scalar() forces it to return a single value.

Ronald



More information about the DBIx-Class mailing list