Provided the rest of your code correctly fetches the attachments, this loop for saving them is broken:{ filename => "suggested filename", payload => "file contents". content_type => "mime type", }
If you're iterating over the array, you should be operating on the *current* element in the loop block, not on the array again. And you should be using each attachment's datastructure properly:# Save the attachments on the local disk foreach $i (@attachments) { my $file = 'test'.$i; #DUMP . @attachments->filename(1); print "cou"; open FILE, '>', $file or die $!; print FILE @attachments; close FILE; chmod 0644, $file; print "cou"; }
foreach my $att ( @attachments ) { my $file = $att->{filename}; open my $fh, '>', $file or die $!; print $fh $att->{payload}; close $fh; chmod 0644, $file; }
In reply to Re: Trying to extract an attachment
by rhesa
in thread Trying to extract an attachment
by Shinama
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |