in reply to Data::Dumper output

Your $request is not what you think (or hope) it to be. Here is a trivial demo:

#!/usr/bin/env perl use strict; use warnings; use HTTP::Request; use Data::Dumper; my $request = HTTP::Request->new; print "Object:\n", Dumper $request; print "Hash:\n", Dumper %$request;

This will produce (versions depending) something like:

Object: $VAR1 = bless( { '_uri' => undef, '_content' => '', '_headers' => bless( {}, 'HTTP::Headers' ), '_method' => undef }, 'HTTP::Request' ); Hash: $VAR1 = '_uri'; $VAR2 = undef; $VAR3 = '_content'; $VAR4 = ''; $VAR5 = '_headers'; $VAR6 = bless( {}, 'HTTP::Headers' ); $VAR7 = '_method'; $VAR8 = undef;

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. The Basic Debugging Checklist may help you to pinpoint where that happens.


🦛

Replies are listed 'Best First'.
Re^2: Data::Dumper output
by Bod (Parson) on May 08, 2021 at 11:06 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.

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

      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.