Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Re: DBI execute() args in array format (or similar) possible?

by snafu (Chaplain)
on Aug 13, 2002 at 03:53 UTC ( [id://189701]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: DBI execute() args in array format (or similar) possible?
in thread DBI execute() args in array format (or similar) possible?

It can't be the same because the script didn't work with execute(@args) but it does work with

execute(eval{join(',',@args),return(@args)});
*shrug* I don't know why...it just does.

One possible explanation is that the execute method is looking for separate arguments and not a list. Thus, I am taking a list and turning it into arguments.

summary of what I think is happening: The execute() method wants distinct arguments ie
execute(arg1,arg2,arg3) vs execute(qw(arg1 arg2 arg3)) which is the same, of course, as execute(@args). The latter 2 examples don't work possibly because its a list instead of separate and distinct scalars respective to the number of place holders in the prepare() statement.

Does execute() not work this way?

Updated: Fixed syntax mistake with qw().

_ _ _ _ _ _ _ _ _ _
- Jim
Insert clever comment here...

Replies are listed 'Best First'.
Re: Re: Re: Re: DBI execute() args in array format (or similar) possible?
by dws (Chancellor) on Aug 13, 2002 at 04:36 UTC
    Brother snafu, I fear you have stumbled onto a series of incantions that appear to work, but that you still do not understand the underlying problem. Consider:   eval {join(',', @args), return(@args)} has the same affect as   eval {return(@args)} since the join() has no side-effect. In turn, these have the same effect as     eval {@args} and   @args

    The execute() method wants distinct arguments ie execute(arg1,arg2,arg3) vs execute(qw(arg1,arg2,arg3)) which is the same, of course, as execute(@args).

    if @args hold (1,2,3), then

    • execute(1,2,3);
    • execute(qw(1 2 3));
    • execute(@args)
    are equivalent, but
    • execute(qw(1,2,3));
    is not equivalent, since qw(1,2,3) is an list that contains a single element. It's the whitespace that's significant in qw(), not the commas.

      Oops! Don't you hate it when you put something in your writeup that is a typo? Note the change I made to my post prior to your reply. I fixed my typo.

      Now, I absolutely agree with your statements. This is why I am so baffled by the situation and get this...it works now using the simple execute(@args) but I swear on everything I know that I did *not* make any changes to the code with the exception of changing to '@args' from the join() statement. However, that works now. It is all very strange and indeed I bet that I will stumble across this little phenomenon again somewhere. Maybe it was the command line args I was using *shrug*. If you read my other posts you will see that @args was most certainly giving off the correct number of elements (I pasted a few outputs where I was trying to show that...they are numbered elements).

      Anyway, I sincerely appreciate all of your comments.

      _ _ _ _ _ _ _ _ _ _
      - Jim
      Insert clever comment here...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://189701]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found