I won't be able to test/debug this until at least tomorrow, but I can tell
you right now that part of the issue is that you don't have a good grasp yet
of scoping in Perl. I recommend that you look for an article called "Coping
with Scoping" that is on the Internet. In addition, you should look at the
man pages for my and use strict;
C:\> perldoc -f my
C:\> perldoc strict
The basic gist of what my() does is that it declares a variable to the local
block. Once the variable falls out of scope, it is destroyed, much like
variables in C. (well, not exactly the same, but close enough for the scope
of this conversation)
for example:
foreach(@array){
my($first,$middle,$last) = split /,/,$_;
print "$last,$first\n";
}
In the example above, it is not necessary to undef() the scalars in the
loop, because they are separate variables each time. You should always "use
strict" and "use warnings" when you are coding in Perl. You might end up
suppressing some of the errors in the end, but you will end up saving
yourself a lot of time in the long run.
-----Original Message-----
From: Paul Jansen
To: [EMAIL PROTECTED]
Sent: 11/3/02 8:39 PM
Subject: win32-lanman iteration problems
Hi.
I'm having a problem witht he win32-lanman module.
I'm using ActivePerl 620, lanman 1.09.1.
A breakdown of my code is below. I'm trying to get
the members of an array of gloabl groups. It is
failing after the first iteration. I'm suspecting
that this is due to a hash not being undef'ed or
something. I can change the order of the global
groups in the array and still only the first one
succeeds (no matter what the order). Has anyone got
any ideas? The code's a little messy but I've tried
to distill it as much as I can.
* * * * *
use Win32::Lanman;
Win32::Lanman::NetGetDCName("", $domain, \$pdc);
print "pdc is $pdc\n";
$userdomain =~ tr/a-z/A-Z/;
$group_counter = 0;
$user_counter = 0;
@group_array = ("EAU-Messaging Team", "Domain Admins",
"EAU-ESOEServices", "EAU-ONCALL-ADMIN",
"EAU-EPALAN-ADMIN");
print "\nGROUP ACCOUNTS\n\n";
foreach $group (@group_array) {
print "$group -\n";
undef $returned_domain;
undef $returned_group_name;
undef @group_members;
undef %group_members;
($returned_domain, $returned_group_name) =
split(/\\/, $group);
$returned_domain = "EMDAU";
print "returned_group_name is $returned_group_name
-\n";
Win32::Lanman::NetGetDCName("", $returned_domain,
\$group_pdc);
print " group_pdc is $group_pdc -\n";
# if (Win32::Lanman::NetGroupGetUsers($group_pdc,
$returned_group_name, \@group_members)) {
if (Win32::Lanman::NetGroupGetUsers($group_pdc,
$group, \@group_members)) {
foreach $element2 (@group_members) {
# print " $element2\n";
foreach $element3 (keys %{$element2}) {
print " $element3 -
${$element2}{$element3}\n";
}
undef $element2;
undef %{$element2};
}
} else {
print " unable to get members!\n";
print " Sorry, something went wrong; error: ";
# get the error code
$error_code = Win32::Lanman::GetLastError();
print " $error_code\n";
print "
".Win32::FormatMessage($error_code)."\n";
}
}
Thanks,
PJ
http://careers.yahoo.com.au - Yahoo! Careers
- 1,000's of jobs waiting online for you!
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs