Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Devel::Peek Dump() not printing out

by haukex (Bishop)
on Feb 20, 2017 at 17:24 UTC ( #1182361=note: print w/replies, xml ) Need Help??

in reply to Re^2: Devel::Peek Dump() not printing out
in thread Devel::Peek Dump() not printing out

Hi ultranerds,

As I said, the output is to STDERR, which won't be sent to the browser, it'll most likely end up in your server log instead. As far as I can tell, Devel::Peek does not offer an option to change where its output goes, even its tests have to jump through some hoops to get its output. The following is the best I can come up with off the top of my head, perhaps another monk knows a better method.

$ perl -wMstrict 2>/dev/null use Devel::Peek; use Capture::Tiny qw/capture_stderr/; my $dump = capture_stderr { Dump "foo" }; print $dump;

Hope this helps,
-- Hauke D

Replies are listed 'Best First'.
Re^4: Devel::Peek Dump() not printing out
by ultranerds (Hermit) on Feb 20, 2017 at 17:38 UTC
    Aaahh my mistake. I thought you were telling me that I may have somewhere slurping in the STDOUT (i.e a log file). Ok - so I'm now seeing the debugging, but I'm still baffled with it. I'm doing a basic curl request to PayPal:
    my $results = `curl https://$config->{$config->{mode}}->{transacti +on_endpoint}/v1/payments/payment/$_[0] -H "Content-Type: application/ +json; charset=utf-8" -H "Authorization: Bearer $token"`; #my $json_vals = decode_json($results); # also tried just this my $json_vals = JSON->new->utf8->decode($results);
    If I add -v to the command and run it manually, I get:
    curl -v +6FF321593HLCVRQSY -H "Content-Type: application/json; charset=utf-8" +-H "Authorization: Bearer MY_AUTH_TOKEN" * Hostname was NOT found in DNS cache * Trying * Connected to ( port 443 (#0) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS Unknown, Unknown (22): * SSLv3, TLS handshake, Client hello (1): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Server hello (2): * SSLv2, Unknown (22): * SSLv3, TLS handshake, CERT (11): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Request CERT (13): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Server finished (14): * SSLv2, Unknown (22): * SSLv3, TLS handshake, CERT (11): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Client key exchange (16): * SSLv2, Unknown (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Finished (20): * SSLv2, Unknown (20): * SSLv3, TLS change cipher, Client hello (1): * SSLv2, Unknown (22): * SSLv3, TLS handshake, Finished (20): * SSL connection using TLSv1.2 / AES256-SHA256 * Server certificate: * subject: C=US; ST=California; L=San Jose; O=PayPal, Inc.; OU= +PayPal Production; * start date: 2016-01-13 00:00:00 GMT * expire date: 2018-01-13 23:59:59 GMT * subjectAltName: matched * issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Netwo +rk; CN=Symantec Class 3 Secure Server CA - G4 * SSL certificate verify ok. * SSLv2, Unknown (23): > GET /v1/payments/payment/PAY-6KY19646FF321593HLCVRQSY HTTP/1.1 > User-Agent: curl/7.38.0 > Host: > Accept: */* > Content-Type: application/json; charset=utf-8 > Authorization: Bearer MY_AUTH_TOKEN > * SSLv2, Unknown (23): < HTTP/1.1 200 OK < Date: Mon, 20 Feb 2017 17:32:59 GMT * Server Apache is not blacklisted < Server: Apache < paypal-debug-id: a347a7a059ab9 < Content-Language: * < Paypal-Debug-Id: a347a7a059ab9 < Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880 +%26app%3Dplatformapiserv%26TIME%3D1260956504%26HTTP_X_PP_AZ_LOCATOR%3 +D; Expires=Mon, 20 Feb 2017 18:02:59 GMT;; path=/; + Secure; HttpOnly < Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT < Vary: Authorization < Content-Length: 1853 < Connection: close < Content-Type: application/json < + óé ","line1":"19 gaskyns close","c +ity":"Rudgwick","state":"West Sussex","postal_code":"rh123he","countr +y_code":"GB"},"phone":"07769201576","óé ","line1":"19 gaskyns close +","city":"Rudgwick","state":"West Sussex","postal_code":"rh123he","co +untry_code":"GB"}},"related_resources":[{"sale":{"id":"5EH65998225152 +523","state":"pending","amount":{"total":"160.75","currency":"EUR","d +etails":{"subtotal":"160.75"}},"payment_mode":"INSTANT_TRANSFER* Clos +ing connection 0 * SSLv2, Unknown (21): * SSLv3, TLS alert, Client hello (1): ","reason_code":"RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION","protect +ion_eligibility":"INELIGIBLE","parent_payment":"PAY-6KY19646FF321593H +LCVRQSY","create_time":"2017-02-20T16:25:19Z","update_time":"2017-02- +20T16:25:36Z","links":[{"href":" +ments/sale/5EH65998225152523","rel":"self","method":"GET"},{"href":"h +ttps:// +nd","rel":"refund","method":"POST"},{"href":"https://api.sandbox.payp","rel":"paren +t_payment","method":"GET"}],"soft_descriptor":"PAYPAL *TESTFACILIT"}} +]}],"create_time":"2017-02-20T16:25:19Z","update_time":"2017-02-20T16 +:25:36Z","links":[{"href":" +/payment/PAY-6KY19646FF321593HLCVRQSY","rel":"self","method":"GET"}]
    (I'm not in a utf8 session, which is why I guess it looks a bit weird on some parts). The main point though, is that its sending the request as utf8. This is how the string comes out in a Dump();
    SV = PV(0x1143890) at 0x11e5758 REFCNT = 1 FLAGS = (POK,pPOK,UTF8) PV = 0x11a47c0 "Andy\303\255\303\255\303\255\303\255\303\251\303\251 +\303\251 \303\215\303\263\303\251 "\0 [UTF8 "Andy\x{ed}\x{ed}\x{ed}\x +{ed}\x{e9}\x{e9}\x{e9} \x{cd}\x{f3}\x{e9} "] CUR = 26 LEN = 28
    Maybe I'm missing something? It's been a long day!

    UPDATE: Interestingly, if I comment this out of my code: binmode(STDOUT, ":utf8"); ...then it works! (I'm not sure why though, and I don't like things like that! ;))

      Hi ultranerds,

      I wrote about calling external programs at length here (unfortunately not in regards to UTF-8 though), and in fact that thread is about calling curl as well.

      However, personally I would not call an external command at all. Have you tried using LWP::UserAgent, LWP::Simple, or HTTP::Tiny?

      -- Hauke D

        Thanks. Maybe I need to look into WWW::Curl (originally I did it with backticks just because paypal's API system is all over the place, with really shoddy documentation on how to get tokens, and then the transaction id, etc.
        I think I'll give it another look tomorrow when my brain doesn't feel like mush :)


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2020-10-25 05:34 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.