Jul 7, 2006, 6:13 AM
Post #6 of 7
Ok. You need to think a bit more carefully about what it is that you're trying to do. Why do you think that "eval" and $@ is the best way to go about it? That approach is appropriate when you are calling code that might call "die".
Re: [mjgray06] a method to check for existing mysql tables
[In reply to]
You have two situations here. Either the table exists or it doesn't. In the first case your select will return one row and in the second case your select will return no rows. In neither of those cases will an error be generated - so under normal operation $@ will never be set and that code will always act as though the table exists.
That leaves you with two problems. Firstly you need a better way to find out if the table exists or not and secondly you need to know why your "eval" is always setting $@ (i.e. why you're always getting an error).
For the first problem, can I suggest that you forget about checking for errors (as I don't think that will work) and instead think about counting the number of rows that are returned (which will, hopefully, be either zero or one).
As for the second problem - well I can only guess. You'll need to print the value of $@ to see what has gone wrong. My guess (and it's only a guess) would be that you're not using MySQL version 5 and that therefore you don't have an INFORMATION_SCHEMA.
Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks