in reply to Parsing of LDAP entry

Try $entry->get_value( $var, asref => 1 ); seen it in Net::LDAP::FAQ

Replies are listed 'Best First'.
Re^2: Parsing of LDAP entry (get_value( $var, asref => 1 );
by mariusz (Initiate) on Jul 31, 2013 at 06:53 UTC

    Thank you for reply.

    Please take a look for my example:

    (...) my $ref = $entry->get_value ( 'changes', asref => 1 ); print Dumper($ref);

    Execution:

    perl test.pl $VAR1 = [ 'delete: employeeType employeeType: Intern - add: employeeType employeeType: No Longer Employed - add: description description: On 30-07-2013 05:17 removed from source. - add: nsAccountLock nsAccountLock: true - replace: modifiersname modifiersname: cn=mmariusz,ou=people,ou=testENV - replace: modifytimestamp modifytimestamp: 20130730031746Z - '

    So, this is stil "multiline" result in one variable. Probably I need to create some kind of function/object and make a parser for that:

    function magic() { my $string = shift; # some magic should be placed here :) #sample return return @replaced_attrs,@added_attrs,@delete_attrs; }

        Uff solved:

        (...) my $chang = &_changes($entry->get_value("changes")); my %changes = %$chang; sub _changes { my $changesSTR = shift; my (%changes, @tmp); $changesSTR =~ s/\n/ /g; foreach my $element(split(/\s-\s/,$changesSTR)){ if ($element =~ m/(replace|add|delete):\s+([^\s]*)\s*\w+\s +*:\s*(.*)$/) { my ($var1,$var2,$var3) = ($1, $2 ,$3); push @tmp,$var3 ; $changes{$var1}{$var2} .= "@tmp" ; @tmp=undef; } elsif ($element =~ m/(replace|add|delete):\s+([^\s]*)$/ +){ $changes{$1}{$2} .= "undef" ; } } return \%changes; }

        Maybe solution is not pretty, but works ;)