Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

attachment logging

by Bass-Fighter (Beadle)
on Dec 18, 2008 at 11:01 UTC ( [id://731222]=perlquestion: print w/replies, xml ) Need Help??

Bass-Fighter has asked for the wisdom of the Perl Monks concerning the following question:

ok, I posted 2 weeks ago something about logging an attachment. this is what I could make with grand help of webfiend.
#!usr/bin/perl use v5.8.0; use warnings; use strict; use MIME::Parser; my $parser = MIME::Parser->new(); $parser->output_under('/tmp'); my $entity = $parser->parse(\*STDIN); if ( $entity->is_multipart ) { for my $part ( $entity->parts ) { my $head = $part->head; if ( my $filename = $head->recommended_filename ) { print "Attachment name: $filename\n"; } } }
I have 2 mails to test the system. the first gives the output what I want. the second gives this: Can't locate object method "binmode" via package "IO::File" at /usr/lib/perl5/site_perl/5.8.0/MIME/Body.pm line 437. does anyone know how to solve this?

Replies are listed 'Best First'.
Re: attachment logging
by Anonymous Monk on Dec 18, 2008 at 11:10 UTC
    { no warnings; sub IO::File::binmode {} }

      Of course, this is just a band-aid, as binmode actually does something, nowadays even on systems with unixish file semantics. Most likely, the proper fix would be to upgrade IO::File to a later version than is installed, or to copy the code for IO::File::binmode into that subroutine:

      sub binmode { ( @_ == 1 or @_ == 2 ) or croak 'usage $fh->binmode([LAYER])'; my($fh, $layer) = @_; return binmode $$fh unless $layer; return binmode $$fh, $layer; }
        and where in my code must I set this?, srry, I'm still a rooky in perl. just 3 weeks of experience with this...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://731222]
Approved by ccn
Front-paged by Arunbear
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-04-24 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found