Hi Monks, Been a long time since I have last seeked wisdom from the Perl Monks. =D
I have been working on some scripts at work, and they have me stumped! Basically, I am running a linux server, and have procmail set up to recieve email with a certain subject, and pass the attachment to a perl script. The perl script verifies the name of the attachment and puts it in the proper directory based on the name.
Here is the thing, I have a certain file overture.txt that writes properly as ASCII Text (file overture.txt). It gets sent as a 7bit Plain Text file.
The other file, Google, has no .txt extention (and cant), but it still gets sent as a 7bit Plain Text file, but it shows up as "Data" when I do a file Google from the prompt. Allow me to post my code...
#!/usr/bin/perl use MIME::Parser; open LOG, ">>/home/autotasks/.procmail/inputlog"; # Create MIME::Parser mail object my $mime = MIME::Parser->new; $mime->output_to_core(0); my $entity = $mime->parse(\*STDIN) or die "Parse failed\n"; foreach my $part ($entity->parts) { my $filename = $part->head->recommended_filename; if ($filename eq 'overture.txt') { my $sender = $part->head->get('From',0); #save file to overture directory and log printf LOG "Overture: $sender\n"; open OVERTURE, ">/home/autotasks/bidWatch/over +ture.txt"; printf OVERTURE $part->bodyhandle->as_string; close OVERTURE; } elsif ($filename eq 'Google') { my $sender = $part->head->get('From:',0); my $filepath = "/home/autotasks/pricemonitor/$ +filename"; printf LOG "$filename: $sender$filepath\n"; #open BIDWATCH, ">$filepath"; #open BIDWATCH, ">/home/autotasks/pricemonitor/Google"; open (BIDWATCH, ">:crlf", $filepath); printf BIDWATCH $part->bodyhandle->as_string; close BIDWATCH; } }
As you can see, I have tried a couple diferent methods of opening the filestream, and even tried adding the :crlf thingie. The goal here is to get the file "Google" to write as ASCII Text. =/
Any help would be greatly appreciated!

By Kzin

In reply to Force Ascii Write by Kzin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.