Monks,
I have the following code (*note: IP's have been changed):
splice(@ips, 15);
for $i ( 0 .. $#ips ) {
print "\t $i is @{$ips[$i]},\n";
}
Output:
number 0 is 192.168.36.118 12431 46.08%,
number 1 is 192.168.80.103 4203 1.56%,
number 2 is 192.119.15.61 3627 1.34%,
number 3 is 192.19.125.2 1738 0.64%,
number 4 is 192.217.1.21 1134 0.42%,
number 5 is 192.17.214.10 852 0.32%,
number 6 is 192.2.252.1.768 0.28%,
number 7 is 192.134.77.97 498 0.18%,
number 8 is 192.8.29.90 489 0.18%,
number 9 is 192.11.7.17 409 0.15%,
number 10 is 192.10.191.29 394 0.15%,
number 11 is 192.247.91.18 25 0.09%,
number 12 is 192.229.14.7 231 0.09%,
number 13 is 192.131.192.206 227 0.08%,
number 14 is 192.161.31.247 172 0.06%,
I want to add the first (ip address) and second (number of attempts) columns to their own array. I was able to add the first column with this code:
my @newips = ();
my ($x, $y);
$y = 0;
for ($x = 0; $x < 15; $x++) {
push @newips, $ips[$x][$y]
}
then I tried to add the second column with this code:
my @num = ();
$x = 0;
for ($y = 0; $y < 15; $y++) {
push @num, $ips[$x][$y]
}
Which only prints:
192.168.36.118 12431 46.08%
What is the best way to do this? I read
perllol which got me this far, but now I'm stuck.
Thanks,
Dru
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.