perlloz has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I am pushing a user name and an array of AD groups for that user name into a hash of arrays:
Code: push (@{$newgrouphash{"$newdn"} },"$newgroup");
Later on in my script I would like to be able to access both the username and the user groups from within the hash of arrays:
However I get the $newdn variable printing twice, once blank and then the actual result. Using a dumper, the info looks fine. Is there a better way of accessing the information in a hash of arrays?foreach $newdn ( keys %newgrouphash ) { foreach $group ( @{$newgrouphash{$newdn}} ) {
Sorry, new here, I used the print statements from the previous posters suggestions. The actual data being pushed into the HOA is a lot of code and is an AD query so it wouldn't compile. What I end up with is a key of Bob and an array containing groups: domain users, testing, server team etc
push (@{$newgrouphash{"$newdn"} },"$newgroup"); foreach $newdn (sort keys %newgrouphash ) { print "Name:$newdn\n\t"; foreach $group ( sort @{$newgrouphash{$newdn}} ) { + if (!($group =~ /CN=Domain Users/i)) { # print "$group, "; + $res = `dsmod group $group -rmmbr \"$newdn\"`; + print "$res\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Hash of arrays
by NetWallah (Canon) on Dec 28, 2012 at 06:23 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 07:13 UTC | |
by CountZero (Bishop) on Dec 28, 2012 at 07:32 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 07:45 UTC | |
by Anonymous Monk on Dec 28, 2012 at 07:47 UTC | |
by NetWallah (Canon) on Dec 28, 2012 at 07:53 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 07:56 UTC | |
by ww (Archbishop) on Dec 28, 2012 at 12:56 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 08:05 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 08:25 UTC | |
by Anonymous Monk on Dec 28, 2012 at 07:32 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 08:07 UTC | |
Re: Hash of arrays
by Anonymous Monk on Dec 28, 2012 at 05:57 UTC | |
Re: Hash of arrays
by 7stud (Deacon) on Dec 28, 2012 at 10:01 UTC | |
by perlloz (Initiate) on Dec 28, 2012 at 10:20 UTC | |
by NetWallah (Canon) on Dec 28, 2012 at 18:54 UTC | |
Re: Hash of arrays
by Anonymous Monk on Dec 28, 2012 at 14:00 UTC |
Back to
Seekers of Perl Wisdom