Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: Hash of arrays

by CountZero (Bishop)
on Dec 28, 2012 at 07:32 UTC ( [id://1010659]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hash of arrays
in thread Hash of arrays

How can we know why things get printed twice? The code you showed does not even have a print statement!

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")
You are not pushing an array of AD groups into a HoA. You are pushing the stringified version of a scalar into your HoA. For a start, drop all the double quotes around your variables. They serve no purpose. Then check whether $newgroup indeed contains a reference to your array of AD groups.

And finally show us the code you use to output this data.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^4: Hash of arrays
by perlloz (Initiate) on Dec 28, 2012 at 07:45 UTC
    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";
      Data Dumper Data Dumper Dumps the Data so the problem of accessing the HoA is seperated from populating the HoA

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1010659]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-03-19 04:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found