in reply to "Modification of non-creatable array value attempted, subscript -1" Error

Can anyone let me know what I'm doing wrong?

Well, a bunch of stuff really. Or at least, if not wrong, then sub-optimum. But not so much that would generate the error you describe. My best guess at the cause of your error is that one of your calls to the module is failing (no entries in a list perhaps) and that code that is called subsequently is making bad assumptions. The error itself is caused by trying to modify the last element (the -1 bit) of an empty array - the element doesn't exist and can't be modified. You are using a rather old version of Perl and possibly an old version of the module so the first thing that would be worth trying is updating to the latest version of the module.

As for the other stuff I alluded to:

  1. Always use strictures (use strict; use warnings; - see The strictures, according to Seuss)
  2. Use the three parameter version of open and use lexical file handles: open my $inFile, '<', $fileName or die "Can't open $fileName : $!"
  3. foreach ($_) only iterates once so isn't doing anything interesting in your code
  4. Generally use explicit variables rather than the default variable in general code to make the code easier to read and to avoid nasty bugs due to $_'s contents changing at unexpected times

I'd rework the code to look something like the following (untested):

#!/usr/bin/perl use strict; use warnings; use Net::Whois::ARIN; my $file = "file_containing_IPs.txt"; open my $inFile, '<', $file or die "Unable to open $file: $!\n"; my $w = Net::Whois::ARIN->new ( host => 'whois.arin.net', port => 43, timeout => 30, ) or die "Can't access server: $!\n"; while (defined (my $line = <$inFile>)) { chomp $line; next if !length $line; for my $net ($w->network ($line)) { printf "CIDR: %s\tNetName: %s\tNetHandle: %s\n", $net->CIDR, $net->NetName, $net->NetHandle; } } close $inFile;
True laziness is hard work