http://www.perlmonks.org?node_id=239765


in reply to sql query subroutine check

You can simplify parameter fetching substantially.

my ($cmd, @place_holders) = @_;

That doesn't explicitly stringify the place holders, but I'm not sure it's necessary in your code. You don't need the double quotes around variables-as-arguments in connect(), either, unless you're doing something really complicated. (My guess is that you're not.)

Be cautious with your return. In scalar context, since it's an array, you'll get the number of elements in the array. This may or may not be what you want.

Connecting and disconnecting on every pass through the sub can be expensive.

You may want to use Carp instead of die for error messages. It can be a bit friendlier.

Replies are listed 'Best First'.
Re: Re: sql query subroutine check
by maksl (Pilgrim) on Mar 01, 2003 at 22:10 UTC
    thanks for your thoughts chromatic i'll take them in account :))
    i have already fallen under the trap you mentioned (getting the numbers of the return array and not the expected values) .. son now i'm more cautious
    the above is not under heavy load .. it's for a friend .. doing it in freetime