|No such thing as a small change|
Re^11: Making an automatic counter adder for all webpagesby polettix (Vicar)
|on Dec 27, 2007 at 23:27 UTC||Need Help??|
You should really consider getting some basic text about Perl. Anyway...
For the second time, this is plain wrong:
Where is $db? Why do you think that these is going to get you the page counter from the DB? Did you actually try this? What was the result? What ended up in $counter? I think you're not doing your part of the work here, because you continue do discuss without trying anything. There's a time for theory, and a time for practice. And you're not practicing.
Second, I really don't understand why you're so reluctant to use my solution. You're trying all possible variations, both working and not, and I simply don't understand why. I usually try to understand if and why a solution works, before proposing alternatives and asking for a discussion on them.
Third, there's no function in the DBI interface that lets you extract a single item from the database. None I am aware of, anyway. The closest one is the extraction of an array/list, so we have to stick to it. To be fair, even if it's called selectrow_array, it actually returns a LIST. You can read in the documentation what the difference is. For our case, it's certainly true that the following will both work:
when we know in advance that the returned list will contain only 1 element. I simply prefer the former, because it puts the desired value directly into the scalar variable $counter. This is not the case of the second approach, that obliges you to get $counter to take the real value of the counter. Some hours on perldata seem appropriate.
Regarding the use of the parentheses with print, you can do whatever you want. I tend to follow the advice in "Perl Best Practices" and avoid parentheses with the built-in functions and operators, but you can decide to always use parentheses in your code, and we'll all be happy.
Be sure to do your hard work before returning for more explainations. It's ok to be confused, but if you don't do anything, not even try what you write, you're just giving me the impression that you value your time much more than mine. I'm not going to be so tolerant the next time.
Hey! Up to Dec 16, 2007 I was named frodo72, take note of the change! Flavio