As well as taking on board other comments, you may want to change your approach to something like this:
#!/usr/bin/perl -w
use strict;
# sample data
my @column_1 = qw(13 14 10 34 73 64 48 52 51 74 8 85 36 74 34 53 9 86
+ 59 15 25);
my @column_2 = qw(3 74 98 185 36 74 34 201 99 86 59 15 25 123 134 16
+202 73 64 48 52);
# "good" numbers
my %col_1_good = map { $_, 1 } (11..49);
my %col_2_good = map { $_, 1 } (101..199);
# "fair" numbers
my %col_1_fair = map { $_, 1 } (8..10, 50..52);
my %col_2_fair = map { $_, 1 } (98..100, 200..202);
my @good_pairs = ();
my @fair_pairs = ();
for my $i (0..$#column_1) {
if ( $col_1_good { $column_1[$i] } && $col_2_good { $column_2[$i]
+} ) {
push @good_pairs, "$column_1[$i] $column_2[$i]";
}
elsif ( $col_1_fair { $column_1[$i] } && $col_2_fair { $column_2[$
+i] } ) {
push @fair_pairs, "$column_1[$i] $column_2[$i]";
}
}
print join "\n", "Good Numbers:", @good_pairs, "\nFair Numbers:", @fai
+r_pairs;
cLive ;-)
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.