Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Data::Dumper output

by Bod (Parson)
on May 08, 2021 at 11:06 UTC ( [id://11132269]=note: print w/replies, xml ) Need Help??


in reply to Re: Data::Dumper output
in thread Data::Dumper output

It is therefore highly probable as everyone else has surmised that you have accidentally stringified $request at some point in the code you have not shown.

Stupid, Stupid, Stupid me!!!

I was trying to print with:

print Dumper %$request . "\n";
Removing the concatenated return character gives...
$VAR1 = '_content'; $VAR2 = 'visibility=HASH(0x26db708)&specificContent=HASH(0x26c2398)&li +fecycleState=PUBLISHED&author=urn%3Ali%3Aperson%3AGKiAGefMOA'; $VAR3 = '_uri'; $VAR4 = bless( do{\(my $o = 'https://api.linkedin.com/v2/ugcPosts')}, +'URI::https' ); $VAR5 = '_headers'; $VAR6 = bless( { 'content-type' => 'application/x-www-form-urlencoded' +, 'content-length' => 121, 'hash(0x26db3a8)' => undef, '::std_case' => { 'hash(0x26db3a8)' => 'HASH(0x26db3a +8)' } }, 'HTTP::Headers' ); $VAR7 = '_method'; $VAR8 = 'POST';
Sorry for having a senior moment...

Replies are listed 'Best First'.
Re^3: Data::Dumper output
by parv (Parson) on May 08, 2021 at 11:28 UTC
    It is therefore highly probable as everyone else has surmised that you have accidentally stringified $request at some point in the code you have not shown.

    ...

    I was trying to print with:

    print Dumper %$request . "\n";

    Removing the concatenated return character gives...

    ...

    To continue to use \n, use a list with print ...

    # Need to use "Dumper()" else "\n" will be swallowed by "Dumper ... ;" + print Dumper( ... ), qq[\n];
      To continue to use \n, use a list with print ...

      Yes. Although I'd use a separate line for clarity

      print Dumper $data_structure; print "\n";
      I just feel that is clearer and less prone to the sort of error I created.

        To continue to use \n, use a list with print ...

        Yes. Although I'd use a separate line for clarity

        print Dumper $data_structure; print "\n";

        Just use say:

        say Dumper $data_structure;

        say outputs a trailing newline unless the arguments already contain a trailing newline.

        I just feel that is clearer and less prone to the sort of error I created.

        I'm no Lisp guy, but using a few more brackets helps to avoid ambiguity and misunderstandings between humans and computers. If you call a function or method, add brackets around the argument list. That's what I do, with only very few exceptions - mostly stuff that is listed in perlfunc, but behaves more like a keyword or a C macro (__FILE__, __LINE__, __PACKAGE__, do, eval, package, use, require) than like a function.

        I would have written ...

        say Dumper($data_structure);

        ... in code for perl 5.10 and newer (i.e. with use v5.10 in the file), or ...

        print Dumper($data_structure),"\n"; # or print Dumper($data_structure)."\n";

        ... in code for older perls.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11132269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 14:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found