in reply to Re: Cleaning up Code
in thread Cleaning up Code
Thank you I will take your advice here.What fetchrow_array returns in scalar context is undocumented. $data1 = $sth->fetchrow_array(); is wrong. If you want to the first field, use ($data1) = $sth->fetchrow_array();
I do ultimately call $dberror in my html code yes. I do not understand what you mean by stating I put both into it? Again please forgive me this is my first attempt at coding anything.Is the contents of $dberror text of HTML? You put both into it. At wor +st, this could be an opening for a cross-site scripting attack.
I was under the impression that this was proper usage... All the examples I discovered on the web used the & before the subroutine.All over, you are instructing Perl to ignore prototypes. Why do you us +e & on your subroutine calls?
Again please forgive my inexperience here... I did a fast google search to find the benefit in using "my()".. am I correct in stating the primary reason in using "my()" is so that the variables are completely hidden from the outside?I note a distinct lack of my. Use use strict;!
I actually want it to return with zero rows, I do plan on adding DBI error codes for my prepare and execute commands.Something tells me you don't use warnings either. ("if ($data1 ne $dig +est1)" would warn if fetchrow_array returned zero rows.) Use use warn +ings;!
My goal with this statement is to see if my @row1 has 6 elements, and if it does proceed on. So if I read what you stated, I could accomplish the same thing by doing thisWhy is six in quotes in "if (scalar @row1 == "6")"? You want to compar +e with the number 6, not the string "6" (which would be converted to +a number by ==). The scalar is useless too. == creates a scalar conte +xt, so scalar is redundant.
??if (@row1 == 6) { other code here ... };
Thank you for this! In trying to understand how this statement works, could I trouble you once more to explain how this exactly works? Again Thank you for you help thus far!!for my $row ( 1 .. $#rows ) { if (@{ $rows[$row] } == "6") { my @entry = (@required , @row); ... } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Cleaning up Code
by ikegami (Patriarch) on Dec 10, 2008 at 03:37 UTC | |
by atmosphere (Novice) on Dec 10, 2008 at 04:38 UTC | |
by ikegami (Patriarch) on Dec 10, 2008 at 06:17 UTC | |
by atmosphere (Novice) on Dec 10, 2008 at 15:12 UTC | |
by ikegami (Patriarch) on Dec 16, 2008 at 04:13 UTC | |
|