in reply to Need help assembling a list

Assuming you have at least as many CVE's as IP addresses, I would read in the CVE's, shuffle them, and then assign the first IP address to the first CVE, the second IP address to the second CVE, etc.

Unless the list of CVE's is so large you cannot slurp them into memory, this should work reasonably fast.

Quick, dirty and untested code:

use 5.010; use strict; use warnings; use Scalar::Util qw [shuffle]; my @ips = `cat ip_addresses`; my @cves = shuffle `cat cves`; chomp @ips; chomp @cves; while (@ips) { say "IP address $_ gets CVE ", shift @cves; }

Replies are listed 'Best First'.
Re^2: Need help assembling a list
by hbm (Hermit) on Jan 27, 2009 at 15:59 UTC

    JavaFan I haven't used say or shuffle, but shouldn't it be the following?

    use 5.10; use List::Util qw[shuffle];
      but shouldn't it be the following?
      use 5.10;
      No:
      $ perl -M5.10 -e1 Perl v5.100.0 required (did you mean v5.10.0?)--this is only v5.10.0, +stopped. BEGIN failed--compilation aborted.
      use List::Util qw[shuffle];
      You are correct. shuffle is found in List::Util, not Scalar::Util.

        Ah, now I see there are many ways to enable say, including yours:

        use 5.010; use 5.10.0; use feature ':5.10.0'; use feature 'say';

        Or even -E on the command line.

Re^2: Need help assembling a list
by spstansbury (Monk) on Jan 30, 2009 at 13:53 UTC
    Thanks for your help! Scott...