Hi Andrej,

On Wednesday, 28. February 2007 04:05, Andrej Ricnik-Bay wrote:
> Sorry for asking something that's probably trivial;  I'm trying to
> pass an $entry to a series of functions that do some checking
> and build an array for a modify operation as they go.
>
> But for some reason I can't seem to access values.
>
>         if( $found_empNo == 1 ){
>           update_edir( $entry, $hrEmpNo );
>           throw_to_syslog("Found employeeNumber $empNo in eDir for
> user $cn; checking to see whether data needs updating")  if ( $debug
> );
>         }
>
> and update_edir:
> sub update_edir{
>   my $entryptr=$_[0];
>   my $getem=$_[1];
>   my $newmesg;
>   my @newattrs;
>   # bless $entryptr, "Net::LDAP::Entry";

Thank god this is commented.
Never blindly re-bless something. 
The $entryptr is already blessed !

>   if(! defined $entryptr ){
>     return;
>   }
>   if(! defined $getem ){
>     return;
>   }
>
> # testing for the 'interesting' fields from HR
>   chkPrfName( $entryptr, ${$hr{ "$getem" }}[3], [EMAIL PROTECTED] );
>    ...
>   chkMngrPosID( $entryptr, ${$hr{ "$getem" }}[18], [EMAIL PROTECTED] );
> }
>
> And one of the other routines:
> sub chkPrfName {
> #  my ( $entry, $field, $attrs ) = @_ ;
>   my $entry = $_[0];
>   my $field = $_[1];
>   my $attrs = $_[2];
>   if(! defined $field ){
>     return;
>   }
>   if(  $field ne "" ){
>     print(  "$entry->get_value( 'preferredName' ) $field\n"  ) ;

Don't put the evaluation statement inside quotes:

      printf $entry->get_value( 'preferredName' )."$field\n";

should do.

> }
>
> And all I see with that print-statment is:
> Net::LDAP::Entry=HASH(0x8a29160)->get_value( 'preferredName' )

The problem were the double quotes.
There are some restrictions regarding expression evaluation inside quotes.

If this is fixed it hould work.

> I did experiment with references, but that only gives me errors
> that say the reference isn't blessed.  If I bless it I get an error
> saying that it's not a reference.
No need to work with references of objects.

A Perl object is simply a bledded reference.

Peter

-- 
Peter Marschall
[EMAIL PROTECTED]

Reply via email to