if (not defined($dnsoptions[0])) { print "dnsoptions is null or undefined, going on to the next subnet\n"; next;

if (join(" ",@dnsoptions) =~ /Error 48: This subnet does not exist./) {

# call "getsubnetlst.exe", passing $subnet as one of the parameters @subnetpart2 = `./getsubnetlst.exe -u xx-p xx -a $subnet -t network -o Rich`; # now loop through each element of the array @subnetpart2, which looks like this - # ########################################################################## # "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128" # ########################################################################## # pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as # a parameter to the cli "getobjectlst.exe".

if (not defined($dnsoptions[0])) { print "dnsoptions is null or undefined, going on to the next subnet\n"; next;

if (join(" ",@dnsoptions) =~ /Error 48: This subnet does not exist./) {

# call "getsubnetlst.exe", passing $subnet as one of the parameters @subnetpart2 = `./getsubnetlst.exe -u xx-p xx -a $subnet -t network -o Rich`; # now loop through each element of the array @subnetpart2, which looks like this - # ########################################################################## # "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128" # ########################################################################## # pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as # a parameter to the cli "getobjectlst.exe".

Error 48: This subnet does not exist. 146.149.0.0/16 getobjectlst.exe :146.149.0.0/16: Error code = 48 dnsoptions is null or undefined, going on to the next subnet ==================================== Checking 161.16.0.0/16

Error 48: This subnet does not exist. 161.16.0.0/16 getobjectlst.exe :161.16.0.0/16: Error code = 48 dnsoptions is null or undefined, going on to the next subnet ==================================== Checking 161.56.0.0/16

Error 48: This subnet does not exist. 161.56.0.0/16 getobjectlst.exe :161.56.0.0/16: Error code = 48 dnsoptions is null or undefined, going on to the next subnet ==================================== Checking 162.2.0.0/16

Error 48: This subnet does not exist. 162.2.0.0/16 getobjectlst.exe :162.2.0.0/16: Error code = 48 dnsoptions is null or undefined, going on to the next subnet ==================================== Checking 162.5.0.0/16

if ( @dnsoptions and $dnsoptions[0] = '' ) { print "dnsoptions is null or undefined, going on to the next subnet\n"; next; }

# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have # the nicely formatted output. We'll have to check for both cases here. # Let's check the unsuccessful case first. The condition below checks if # the first element of @dnsoptions array has the following text in it - # "Error 48: This subnet does not exist." in it.

if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {

# now loop through each element of the array @subnetpart2, which looks like this - # ########################################################################## # "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128" # ########################################################################## # pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as # a parameter to the cli "getobjectlst.exe".

foreach my $line ( @subnetpart2 ) {

# get the 2nd field from the left my $snetpart2 = (split/"\s+"/, $line)[1];

if ( @dnsoptions and $dnsoptions[0] = '' ) { print "dnsoptions is null or undefined, going on to the next subnet\n"; next; }

# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have # the nicely formatted output. We'll have to check for both cases here. # Let's check the unsuccessful case first. The condition below checks if # the first element of @dnsoptions array has the following text in it - # "Error 48: This subnet does not exist." in it.

if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {

# now loop through each element of the array @subnetpart2, which looks like this - # ########################################################################## # "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128" # ########################################################################## # pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as # a parameter to the cli "getobjectlst.exe".

foreach my $line ( @subnetpart2 ) {

# get the 2nd field from the left my $snetpart2 = (split/"\s+"/, $line)[1];

if ( @dnsoptions and $dnsoptions[0] = '' ) { print "dnsoptions is null or undefined, going on to the next subnet\n"; next; }

# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have # the nicely formatted output. We'll have to check for both cases here. # Let's check the unsuccessful case first. The condition below checks if # the first element of @dnsoptions array has the following text in it - # "Error 48: This subnet does not exist." in it.

if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {

# now loop through each element of the array @subnetpart2, which looks like this - # ########################################################################## # "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128" # ########################################################################## # pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as # a parameter to the cli "getobjectlst.exe".

foreach my $line ( @subnetpart2 ) {

# get the 2nd field from the left my $snetpart2 = (split/"\s+"/, $line)[1];

It's time for you to step up to the plate and try to do some troubleshooting/debugging, which you haven't done yet, rather than expecting someone else to provide you with a fully tested and debugged script that meets your specifications. If you need someone else to write this for you, then you should hire someone.

Belive me sir/mam, I have tried on my own all day and every day, trying different options. I am not sitting back and waiting if thats what you mean.

I have posted here as a novice/beginner since I am not up to speed yet. You experts have tought me a thing or two, but I keep getting over my head and hard to learn such advanced coding.

Please understand, I am not looking for a easy meal ticket, just some guidence and help during these trying days.

Please understand. I think its simple to the fact that when the output gets the Error 48, the second and most important part is not being read some-how. The rest is working fine, its just that one part.

Your getobjectlst.exe program is sending "Error 48: This subnet does not exist." to STDERR.

When you use backticks, your @dnsoptions array is populated with the STDOUT stream and doesn't see the STDERR stream. You need to either redirect STDERR to STDOUT or use one of Perl's other methods for executing the external command that reads STDERR.

Using the IPC::Open3 module would be best, but at your current level of understanding, that method would confuse you more than you are now.