CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [richsark] need another set of eyes on my perl script: Edit Log



FishMonger
Veteran / Moderator

May 1, 2009, 10:44 AM


Views: 4757
Re: [richsark] need another set of eyes on my perl script

I don't have the getobjectlst.exe porgram that you're using in that script, so before I work up an example using some other command, see if this adjustment to Tyler's script does what you need.

Change:

Code
if (@dnsoptions) { # @dnsoptions is not empty


To:

Code
if (@dnsoptions and $dnsoptions[0] ne '') { # @dnsoptions is not empty


In cases like this it's very helpful to use Data::Dumper to inspect the contents of vars.

http://search.cpan.org/~ilyam/Data-Dumper-2.121/Dumper.pm

So, in your case you could do:

Code
@dnsoptions = `./getobjectlst.exe -u Xxx-p Xxx -a $subnet -o rich`; 
print Dumper \@dnsoptions

What does it show for the value of $VAR1

You can also run this test script, which may give a better idea of what I'm talking about.

Code
#!/usr/bin/perl 

use strict;
use warnings;
use Data::Dumper;

my @array;

# run the script then uncomment this next line and see the difference
#$array[0] = '';

if( @array ) {
print "yes\n";
}
else {
print "no\n";
}

print Dumper \@array;



(This post was edited by FishMonger on May 1, 2009, 10:45 AM)


Edit Log:
Post edited by FishMonger (Veteran) on May 1, 2009, 10:45 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives