Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

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,
0
bt707
Asked:
bt707
  • 3
  • 2
1 Solution
 
ozoCommented:
use Data::Dumper;
print Dumper  $ld;
0
 
bt707Author Commented:
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,
0
 
bt707Author Commented:
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.
0
 
ozoCommented:
&writeAdDebug(qq{555-00 ld is: }.(Dumper $ld).qq{<br>\n});
0
 
bt707Author Commented:
Thanks ozo, just wasn't getting it to work.

Thanks!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now