Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
If you set it to print the code, it does so and displays valid mySQL syntax. I find it interesting that die doesn't work within DESTROY, but I guess I could understand that. My tied hash is going out of scope by default when the namespace is cleared at the end of the script's execution. Why is it not achieving the desired effect?package Test; my @STRUCTURE = qw(name test); my $TABLENAME = "test"; my $KEY = "id"; *DBH = *main::DBH; . . sub DESTROY { my($impl) = @_; my $keyval = $impl->{$KEY}->{value}; my @list; my $time = time; push(@list,"timestamp='$time'"); foreach(@STRUCTURE){ my $val = $impl->{$_}->{value}; $val =~ s/'/\\'/g; push(@list,"$_='$val'"); } my $string = join ",",@list; $DBH->do(" UPDATE $TABLENAME SET $string WHERE $KEY=$keyval LIMIT 1 "); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash Tie's DESTROY & DBI
by perrin (Chancellor) on Jan 10, 2002 at 21:34 UTC | |
|
Re: Hash Tie's DESTROY & DBI
by gav^ (Curate) on Jan 10, 2002 at 22:22 UTC | |
by tretin (Friar) on Jan 11, 2002 at 05:16 UTC | |
by runrig (Abbot) on Jan 11, 2002 at 05:23 UTC | |
|
Re: Hash Tie's DESTROY & DBI
by Ryszard (Priest) on Jan 11, 2002 at 06:46 UTC |