On Tue, May 17, 2005 at 04:17:15PM -0700, Jonathan Leffler wrote:

> Also, the example code used $dbh->can()
> as if it returns some sort of subroutine reference - whereas the
> manual only says it returns true or false.  Is the DBI manual
> inaccurate or just incomplete and it actually returns something
> usable?

There's fairly deep magic going on here.  Returning a code-ref is
undocumented because of potential problems. And guess what...
here's a problem.

FYI: see the UNIVERSAL::can() docs for background info.

> On 5/17/05, Konstantin Solodovnikov <[EMAIL PROTECTED]> wrote:
> > I'm having a problem with DBD::Informix when using it's functions via a
> > 'goto &$sub' mechanism.
> 
> Que? What on earth is that?  Why do you want to use it?  Where did it ever 
> work?

        goto &foo

is like
        return foo(@_) 

but reuses the current sub's call frame and args.

It's rarely used and less rarely needed.

        sub prepare_sql
        {
        # uncommenting the next line will avoid core dump
        # return $DBH->prepare( 'select * from ');
         my $sub = $DBH->can( 'prepare');
         @_ = ( $DBH, 'select * from ' );
         goto &$sub;
        }

Messing with @_ before using goto & is just asking for trouble.

Bottom line: If it hurts then stop doing it.

Tim.

Reply via email to