in reply to Getting attachments from request in perl

StackOverflow has a good thread on exactly how HTTP file-uploads work. Are you sure that that unless (@attachments) business is correct? Can you, say, put a Data::Dumper output to a temporary file, to see what it contains?
  • Comment on Re: Getting attachments from request in perl

Replies are listed 'Best First'.
Re^2: Getting attachments from request in perl
by Stetec (Novice) on Jan 18, 2018 at 16:21 UTC
    When I inspect my requests in Mozilla the files are present in each one correctly. The  unless statement should be correct. I also tried  if (scalar @attachments == 0) with the same results. I don't exactly know how should I use Data::Dumper but when I do the first request after restart the file is present and I can open and copy its content normally.
      I don't exactly know how should I use Data::Dumper

      Best to have a quick look at the Data::Dumper documentation. The Dumper() function is exported by default and gives a pretty crude picture of the data. Give it an array and it will treat each element as a separate variable but give it a reference to the array and you see an anonymous array. Dump() and its faster but not always available sibling Dumpxs() are fiddlier but more useful as they can give a more accurate picture.

      Here's a brief example.

      johngg@shiraz ~ $ perl -Mstrict -Mwarnings -MData::Dumper -E ' my @atts = qw{ att1 att2 att3 }; say Dumper( @atts ); say Dumper( \ @atts ); say Data::Dumper->Dump( [ \ @atts ], [ qw{ *atts } ] ); say Data::Dumper->Dumpxs( [ \ @atts ], [ qw{ *atts } ] );' $VAR1 = 'att1'; $VAR2 = 'att2'; $VAR3 = 'att3'; $VAR1 = [ 'att1', 'att2', 'att3' ]; @atts = ( 'att1', 'att2', 'att3' ); @atts = ( 'att1', 'att2', 'att3' );

      I hope this is helpful.

      Cheers,

      JohnGG

        Thank you for explanation. When I use Dump function on attachments array I get string "@attachments = ();". I really don't know what kind of anomaly is this. I just found out that I can get nothing from request, not only file.