perl print hash

Posted on 2012-09-14
Last Modified: 2012-09-14
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.

Question by:bt707
    LVL 84

    Expert Comment

    use Data::Dumper;
    print Dumper  $ld;

    Author Comment


    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]),$$),
          close DEBUG;

    Open in new window

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


    Author Comment

    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.
    LVL 84

    Accepted Solution

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

    Author Closing Comment

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


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now