Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Hash Tie's DESTROY & DBI

by gav^ (Curate)
on Jan 10, 2002 at 22:22 UTC ( #137795=note: print w/replies, xml ) Need Help??


in reply to Hash Tie's DESTROY & DBI

Some error handling might be nice:
$DBI->do("blah"); if ($DBI->err) { print "Error: ", $DBI->errstr, "\n"; }
Also you might want to consider placeholders, it makes quoting and stuff a lot less error prone:
foreach (@STRUCTURE) { push @list, "$_ = ?"; push @vals, $impl->{$_}->{value}; } my $string = join ",",@list; $DBH->do(qq{ UPDATE $TABLENAME SET $string WHERE $KEY=? LIMIT 1 }, undef, @vals, $keyval);
Hope this is of some help.

Replies are listed 'Best First'.
Re: Re: Hash Tie's DESTROY & DBI
by tretin (Friar) on Jan 11, 2002 at 05:16 UTC

    so by saying that die does not work in your script, that means that you tried and die did not work or did not produce any error (or something of that nature) or you assumed it would not, or something else? I am interested to know (since I do not know much about DBI) why it would not work there.

    I know many do not like to useeval because of security reasons but, if you used it (in correspondence w/ $@) would that catch the errors if die did/could not? or would it not work for the same reason die would not/could not?

    thank you for your time

    -tretin
      I know many do not like to use eval because of security reasons

      eval "$data_from_tainted_source" has both security and performance issues.
      eval { block_of_code() } does not (at least not due to the eval itself), and die'ing in an eval then checking $@ is a common method of 'exception handling' in perl.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-05-20 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?