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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.