Sorry John...I described my problem space poorly. I'll try
again.
If I copy an email from Microsoft Outlook to my desktop and then open
that email using a generic text editor, I see lot's of non printable garbage.
This is what I am trying to remove.
Haze
-----Original
Message-----
From: John W. Kennedy [mailto:[EMAIL PROTECTED]]
Sent:
Thursday, September 21, 2006 10:35 AM
To: [EMAIL PROTECTED]
Cc:
[email protected]
Subject: Re: Remove non-ascii
character
[EMAIL PROTECTED] wrote:
> Sorry for the novice
question, but can someone point me in the
> direction of stripping all non
printing non ascii characters from a
> file? The idea is to take microsoft
email and remove all the crud so
> as to create a simple text file for
further parsing.
There is no such thing as "microsoft email". Assuming
that you mean email with an attached DOC file produced by Microsoft Word, then
what you are asking for will not be particularly satisfactory, as not all ASCII
bytes will be text, and not all non-ASCII bytes will be non-text.
But, if
you insist:
use strict;
use warnings;
my ($infilename,
$outfilename) = ('myfile.doc', 'myfile.txt');
open my $infile, '<',
$infilename or die $!; binmode $infile; open my $outfile, '>', $outfilename
or die $!; while (defined (my $c = getc $infile))
{
my $i = ord
$c;
print $outfile $c if ($i >
31 && $i < 128); } close $infile or die $!; close $outfile or die
$!;
--
John W. Kennedy
"The blind rulers of Logres
Nourished
the land on a fallacy of rational virtue."
-- Charles
Williams. "Taliessin through Logres:
Prelude"
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
