I do not understand what you mean by stating I put both into it?
@entry1 contains text and not HTML, right? At the very least, it needs to visit HTML::Entities.
I was under the impression that this was proper usage
It disables prototypes and allows subroutines to be called without parens before they are declared. It was possibly the way to do things in Perl4, but this isn't Perl4.
the primary reason in using "my()" is so that the variables are completely hidden from the outside?
Yes. It limits the scope of the variables. This prevents accidental clobbering of the variables by distant code and it fosters modularity of code. In conjunction with use strict;, typos in variable names are usually caught at compile-time. use strict; helps identify a couple of other type of dangerous code.
my @entry = (@required , @{$rows[$row]}); my $digest = sha1_hex(@entry); my $sth = $dbh->prepare($query); $sth->execute($digest); my ($data) = $sth->fetchrow_array(); ...
I actually want it to return with zero rows
Yes, but you don't want it to warn "Use of uninitialized value in string eq" when it does. defined would be one way of avoiding the warning.
So if I read what you stated, I could accomplish the same thing by doing this
Yes. @row1 == 6 checks if @row has 6 elements. An array in scalar context (as imposed by scalar but also by ==) evaluates to the number of elements in the array.
In trying to understand how this statement works
All variables other than @row1 can lose the "1" without problem. The rows are a little bit trickier since we want to switch to using a loop. Unfortunately, you haven't shown us everywhere @rowX is used — in particular, you haven't shown us where they're created — so our help there is limited.
Basically, I suggested that you create an array @rows whose elements are references to arrays (formerly @row1, @row2, etc). This is commonly called an "array of arrays". Basically, Perl's version of a two-dimensional array. There's perllol on the subject, for starters.
Note: I've updated my post to fix a bug in that code.
In reply to Re^3: Cleaning up Code
by ikegami
in thread Cleaning up Code
by atmosphere
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |