Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: CGI::Carp sometimes fails

by Danny (Hermit)
on May 18, 2024 at 16:43 UTC ( [id://11159527]=note: print w/replies, xml ) Need Help??


in reply to CGI::Carp sometimes fails

What does
print "$file{'receipt', 'file'}\n"
or
use Data::Dumper; print Dumper($file{'receipt', 'file'})
give?

Replies are listed 'Best First'.
Re^2: CGI::Carp sometimes fails
by Bod (Parson) on May 18, 2024 at 18:57 UTC

    Back from eating outside so no longer on my mobile 😊

    #!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use lib ( "$ENV{'DOCUMENT_ROOT'}/../lib", "$ENV{'DOCUMENT_ROOT'}/../.. +/prod/lib" ); use Bod::CRM; use Site::Utils; use Data::Dumper; print "Content-type: text/plain\n\n"; print Dumper $file{'receipt', 'file'}; exit;

    This gives me a 500 error which is not picked up by CGI::Carp

    But - I've tried printing out to a file and $file{'receipt', 'file'} contains the contents of a JPEG image file. Can die and print not handle some encoded characters such as those in an image file?

    I am trying to debug some code that handles file uploads from a webpage and came across this strange behaviour of die working in some places and not others. So I created a simple example to demonstrate it. But it seems it's an encoding issue that is something I am getting everywhere from .htaccess files to blog editing since moving servers 😒

      contains the contents of a JPEG image file.

      I suppose one approach to try and narrow it down would be divide and conquer the contents of $file{'receipt', 'file'}. Split it in half and check both halves. Split the bad half again, etc.

      You said you tried printing the contents to a file. I assume that was successful?

      EDIT: Or instead of divide and conquer maybe try something like:

      my $len = length $str; for(my $i = 1; $i <= $len; $i++) { print substr($str, 0, $i) }

Re^2: CGI::Carp sometimes fails
by Bod (Parson) on May 18, 2024 at 17:43 UTC

    It should be undefined but I'll check when I get back to my desktop and report back. The reason I included "X -" was in case there was a strange value in the variable.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-09-16 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.