Bass-Fighter has asked for the wisdom of the Perl Monks concerning the following question:
again the code:
and here what is inside perltst:#!usr/bin/perl use 5.6.1; use strict; use warnings; use Mail::Internet; use MIME::Parser; my $mail = Mail::Internet->new($ARGV[0]); my $headers = $mail->head()->header_hashref(); my $maximum = 100000; my $mailnummer = int(rand($maximum)); my $from = $headers->{From}->[0]; my $to = $headers->{To}->[0]; my $cc = $headers->{CC}->[0]; if ($cc eq ""){ $cc = 0; } my $date_time = $headers->{Date}->[0]; my $subject = $headers->{Subject}->[0]; if ($subject eq ""){ $subject = 0; } my $parser = MIME::Parser->new(); $parser->output_under('/tmp'); my $entity = $parser->parse($ARGV[0]); my $file; if ( $entity->is_multipart ) { for my $part ( $entity->parts ) { my $head = $part->head; if ( my $filename = $head->recommended_filename ) { $file = $filename; } } }
the command in linux must be: perl emailprogramma3.txt perltst. and then the program will do everything automatically. at this moment the program will only look at the word perltst itself. but I want that the code above this will run through the programFrom from.someone@sent.com Wed Dec 3 09:36:43 2008 Return-Path: <from.someone@sent.com> Received: from [19.168.20.16] ([19.345.456.12]) by mail2.ibb.nl (9.22.41.45678901/3.15.10) with ESMTP id mB56a +hFCh20714; Wed, 3 Dec 2008 09:36:43 +0100 Message-ID: <34567890.12345678@sent.com> Date: Wed, 03 Dec 2008 09:36:55 +0100 From: someone <from.someone@sent.com> User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: perl@recieve.nl CC: zdf@cc.nl Subject: Test voor Michiel 's Perl programma Content-Type: multipart/mixed; boundary="------------000002060003020904090008" This is a multi-part message in MIME format. --------------000002060003020904090008 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit hey, ben benieuwd of dit mailtje goed aankomt in het bestand. Groet, frits --------------000002060003020904090008 Content-Type: text/plain; name="Niet zelf een nummer bedenken!.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Niet zelf een nummer bedenken!.txt" SW4gZfafajkGAGEQRda789UIOKAJkljfqj8q8gdG9ldm9lZ2VuGAOGJHAFfagkl4538daj +a a3QgaGllcnZvb3IgQWRkSXRlbSBvZiBkZgBzdGFuZGFhcmQgcHJvZ3JhbW1hJ3MgdmFuIE +lC Qiag6FGIJ891rgahuClJCQQ== --------------000002060003020904090008--
I know that @ARGV[0] must be changed 2 times in the code, but who can tell me in what?
Bass-Fighter
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: loading files
by poolpi (Hermit) on Dec 22, 2008 at 10:10 UTC | |
by Bass-Fighter (Beadle) on Dec 22, 2008 at 10:37 UTC | |
by almut (Canon) on Dec 22, 2008 at 12:57 UTC | |
by Bass-Fighter (Beadle) on Dec 22, 2008 at 13:55 UTC | |
by almut (Canon) on Dec 22, 2008 at 14:20 UTC | |
|
Re: loading files
by poolpi (Hermit) on Dec 22, 2008 at 13:27 UTC | |
by Bass-Fighter (Beadle) on Dec 22, 2008 at 13:58 UTC | |
by Corion (Patriarch) on Dec 22, 2008 at 14:04 UTC | |
by Bass-Fighter (Beadle) on Dec 22, 2008 at 14:10 UTC | |
by Corion (Patriarch) on Dec 22, 2008 at 14:22 UTC | |
| |
|
Re: loading files
by Anonymous Monk on Dec 22, 2008 at 08:55 UTC | |
by Bass-Fighter (Beadle) on Dec 22, 2008 at 09:21 UTC |