Monks,
I would appreciate it if someone could help me troubleshoot this. When I run this script with warnings and strict, I get the following error message
Use of uninitialized value in join at ./temp1.pl line 36. I've tried everything I can think of and I can't seem to make it disappear. Here is the data it is matching on:
Users/Source Addresses: Top 15 of 7785
=======================================================
192.0.1.241 12773 73.19%
192.163.110.131 3329 1.91%
192.95.212.130 1385 0.79%
192.217.19.201 1266 0.73%
192.8.29.90 1266 0.73%
192.218.182.34 1207 0.69%
192.100.176.66 518 0.30%
192.75.223.242 452 0.26%
192.252.74.124 428 0.25%
192.127.3.10 313 0.18%
192.30.27.2 301 0.17%
192.95.18.74 299 0.17%
192.125.182.179 196 0.11%
No-address 171 0.10%
192.154.47.3 148 0.08%
Users/Destination Addresses: Top 15 of 64512
=======================================================
192.37.214.51 3555 2.04%
here is my script:
1 #!/usr/bin/perl -w
2
3 use strict;
4 #use diagnostics;
5
6 # Declare your variables here
7
8 my $logsum_file = "/exported/analysis/27Dec01.logsum";
9 my $fw_logfile = "/exported/27Dec01.elog";
10
11 my ($topten, @ips);
12
13 # Get the ten ip addresses from the daily fwlogsum report and
14 # store them in an anonymous array @ips
15
16 open REPORT, "$logsum_file" or die "Can't open logsum_file: $!\n";
17 while (<REPORT>){
18 chomp;
19 $topten = 1 if m!^Users\/Source Addresses!;
20 next unless $topten;
21 push @ips, [split /\s+/] if /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
+)/; # create an array of arrays (perldoc perllol)
22 last if /^Users\/Destination Addresses/;
23 }
24 close REPORT, "$logsum_file" or die "Can't close $logsum_file: $!\n
+";
25
26 #Separate ip addresses and number of attempts into separate arrays
27
28 my @newips;
29 my @attempts;
30 my ($x, $y);
31 for ($x = 0; $x < 15; $x++) {
32 push @newips, $ips[$x][0];
33 push @attempts, $ips[$x][1];
34 }
35
36 print "Here are the ips: @newips\n";
Thanks,
Dru
Another satisfied monk.
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.