[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] wrote:
 
> The solution is quite simple:
> $sth->bind_param(1,$var,&{"DBI::$coltype"}());
> 
> But the question is why my version (&{"DBI::$coltype"} ) runs in a
> single script and why it doesn't work after splitting into script and
> module... 

perldoc perlsub:

       To call subroutines:

           NAME(LIST);    # & is optional with parentheses.
           NAME LIST;     # Parentheses optional if
predeclared/imported.
           &NAME(LIST);   # Circumvent prototypes.
           &NAME;         # Makes current @_ visible to called
subroutine.

In other words, &NAME is functionally equivalent to &NAME(@_).

In your original code, when you called &{"DBI::$coltype"}, @_ was empty,
so it worked.  Once you moved the code into a subroutine, @_ was no
longer empty, so you needed to add the parens to make sure the SQL_...
sub was called without any arguments.

Ronald



Reply via email to