There are good answers to your general question above, but one line jumped out at me:
if (($i == 7) | ($i == 14) | ($i == 21) | ($i == 28) | ... ){
The first thing to jump out is the use of a bitwise or instead of a logical or. Correcting that leaves
if (($i == 7) || ($i == 14) || ($i == 21) || ($i == 28) || ... ) {
which still has a problem: unecessary parenthesis
creating single-elements lists, each containing a boolean. Correcting this leaves
if ( $i == 7 || $i == 14 || $i == 21 || $i == 28 || ... ) {
This is correct, but a cursory glance shows that the intent is determine whether $i is a multiple of 7 (or, said another way, that $i is divisible by 7 without remainder). There's an easy way to express that:
if ( $i % 7 == 0 ) {
Phrased this way, you can increase the upper bound on your loop safely without having to add another condition to if
if statement. Anytime you have to change code in more than one place to increase the range of a loop, a flag should go up.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.