Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Do you know where your variables are?
 
PerlMonks  

Mime::parse file output

by SneakZa (Initiate)
on Jun 09, 2013 at 15:53 UTC ( #1037935=perlquestion: print w/ replies, xml ) Need Help??
SneakZa has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Is there a method I can call to get the full pathname of the random directoy mime::parse (output_under) creates for seperate messages? ### Tell it where to put things: $parser->output_under("/tmp");

Comment on Mime::parse file output
Re: Mime::parse file output
by frozenwithjoy (Curate) on Jun 09, 2013 at 15:59 UTC

    According to the docs, you can use $parser->tmp_dir("/my/custom/tmpdir"); to manually set a temp directory. Otherwise, the system default temporary directory is used.

    edit: Just realized you were asking about output directory, not temp directory. It looks like you might be able to use $parser->output_dir("/tmp"); instead of $parser->output_under("/tmp"); to output everything in the same directory if that works for you.

      thats not what im looking for.. i would like to know what that random directory is for later use,, cause there might be multiple sessions of this script running , so everytime it parses a message it creates /tmp/msg-*something and the parts are saved in there..

        Do you need them to be filed in random subdirectories inside a specified directory (rather than everything directly in the specified directory)? If not, then what I said in the edit still stands.

        output_dir
        Causes messages to be filed directly into the given DIRECTORY. It does this by setting the underlying filer() to a new instance of MIME::Parser::FileInto, and passing the arguments into that class' new() method.
        output_under
        Causes messages to be filed directly into subdirectories of the given BASEDIR, one subdirectory per message. It does this by setting the underlying filer() to a new instance of MIME::Parser::FileUnder, and passing the arguments into that class' new() method.
Re: Mime::parse file output
by kcott (Abbot) on Jun 09, 2013 at 17:56 UTC

    G'day SneakZa,

    Firstly, I'll assume you mean MIME::Parser (which is the closest to Mime::parse I can find on CPAN).

    If you look further down the documentation to Specifying output destination, you'll find more details including a link to MIME::Parser::Filer. The output_path(), output_dir() and output_filename() methods look promising; however, depending on what you want to do, other methods may be more appropriate: for instance, if you wanted the pathname in order to perform some cleanup of files, then purge() might be a better choice.

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1037935]
Approved by frozenwithjoy
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2014-04-16 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (413 votes), past polls