spstansbury has asked for the wisdom of the Perl Monks concerning the following question:
I am generating some demo files for a vulnerability reporting tool.
I have generated a list of IP addresses, and a list of NVD/CVE identifiers.
What I want to do is randomly assign a CVE vulnerability to each IP address.
In my mind I want the script to do this:
But, of course, this doesn't work...#!/usr/bin/perl $ip_file = 'ip_addrs'; $cve_file = 'cvd_ids'; srand; open(IPADDRS, $ip_file); open(CVEIDS, $cve_file); my $cve =[]; while (<IPADDRS>) { push(@addrs, $_) } foreach $addr (@addrs) { for $cve (<CVEIDS>) { rand($.) < 1 && ($cve = $_); print "$addr, $cve\n"; } }
Any help would be greatly appreciated!
Best regards,
Scott...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help assembling a list
by JavaFan (Canon) on Jan 27, 2009 at 15:08 UTC | |
by hbm (Hermit) on Jan 27, 2009 at 15:59 UTC | |
by JavaFan (Canon) on Jan 27, 2009 at 16:35 UTC | |
by hbm (Hermit) on Jan 27, 2009 at 18:13 UTC | |
by ikegami (Patriarch) on Jan 27, 2009 at 21:41 UTC | |
by spstansbury (Monk) on Jan 30, 2009 at 13:53 UTC | |
|
Re: Need help assembling a list
by jethro (Monsignor) on Jan 27, 2009 at 15:39 UTC |