Sorry, I don't understand really what your input and desired output is. Thus I can't also not follow what your code wants to do. Can you give us an example of your input and a description what good numbers are.
However, of course, I can rewrite your code to shorten it and make it more Perlish :-)
I assume, that the data comes from a file.
use Tie::CSV_File;
tie my @array, "Tie::CSV_File", $filename, WHITESPACE_SEPARATED;
for my $i (1 .. $#array) {
push @good_nums,
$array[$i-1]->[0] * $array[$i]->[1] *
$array[$i-1]->[1] * $array[$i]->[0];
# Did you really want to compute 4x a multiplication ?!
}
print @good_nums;
Well, I still don't know what's going on :-(
If the data doesn't come from a file, you could also achieve quite the same,
all you have to do is to nest the data:
@array = map {[split]} @array;
# instead of the first two lines of my snippet
Greetings,
Janek
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.