develooper Front page | perl.ldap | Postings from April 2010

Re: Iterating thru array of hashes

Thread Previous
From:
Graham Barr
Date:
April 1, 2010 05:51
Subject:
Re: Iterating thru array of hashes
Message ID:
0C963AFF-BDBA-4AA3-9D0F-7EDBFAE3E525@pobox.com
On Mar 31, 2010, at 10:31 PM, Prashanth Sundaram wrote:
> 
> 
> sub create_user {
>    my(@add_user)=@_;
>    print Dumper(@add_user);
>    for $eachuser (@add_user)
>    {   print "\n==========\n ";
>        #for $attribut (keys %eachuser)
>        #{  
>        #   if ($attribut eq "\n objectClass"){ for (my $j=0; $j < 12;
> $j++){print " objectClass:".$eachuser->{$attribut}[$j]; } }
>        #   print $attribut.":".$eachuser->{$attribut}."\n";
>        #}
>        $dn_add='uid='.$eachuser->{'uid'}.',ou=people,'.$ldap_base;
>        print "dn: $dn_add \n";
>        $new_entry = Net::LDAP::Entry->new;
>        $new_entry->dn($dn_add);
>        $new_entry->add($dn_add,attr => [ %eachuser ]);

I would really suggest you add

use strict;

to the start of your script as there is no such variable %eachuser, you need %$eachuser

Graham.

>        my $mesg_ld = $new_entry->update($ldap_ld);
>        if ($mesg_ld->code)
>        { 
>          logit('err',"Error adding uid:".$eachuser->{'uid'}."with
> uidNumber:".$eachuser->{'uidNumber'},$mesg_ld);
>        }
>        else
>        { 
>          logit('info',"Successfully added
> uid:".$eachuser->{'uid'}."uidNumber:".$eachuser->{'uidNumber'},$mesg_ld);
>        }
>    }
> }
> 
> 
> 
> 
> 


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About