Link to home
Start Free TrialLog in
Avatar of bt707
bt707Flag for United States of America

asked on

perl print hash

In a sub I have:
my $ld = shift;

which I'm just doing a simple print like:
print "ld is: $ld\n";

The $ld is an open to an ldap for a search, but when trying to print this I get:

ld is: Net::LDAP=HASH(0x368a4c)

Can anyone give me an ideal on how to print this out from this format to get the info in the hash? Having some issues and need to try to debug what's going on.

Thanks,
Avatar of ozo
ozo
Flag of United States of America image

use Data::Dumper;
print Dumper  $ld;
Avatar of bt707

ASKER

ozo,

I cannot do that I don't think.

I did not think it would matter, but I'm actually printing it out like:

&writeAdDebug(qq{555-00 ld is: $ld<br>\n});

I have a lot of cgi web scripts that is mostly all Perl and uses a number of .pm files we have in which I'm doing a debug print in this case from one of the .pm files.

so I can only print a debug line by using the sub  writeAdDebug

The sub looks writeAdDebug looks like this:

sub writeAdDebug {
  my $message = shift;

  if ($DEBUG == 1) {
    print STDOUT $message;
  } elsif ($DEBUG == 2) {
    if(open(DEBUG,qq{>>$DEBUGFILE})) {
      my @date=gmtime(time);
      print DEBUG qq{\n},
                  (sprintf q{Date: %0d/%02d/%02d %02d:%02d:%02d -- %d},$date[5]+1900,$date[4]+1,reverse(@date[0..3]),$$),
                  qq{\n$message\n};
      close DEBUG;
    }
  }

Open in new window


Sorry for that, any ideas how I can make it work from that?

Thanks,
Avatar of bt707

ASKER

If I don't have any good options from that then I use your suggestion and go ahead and dump it to a file on server.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bt707

ASKER

Thanks ozo, just wasn't getting it to work.

Thanks!!