<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl Help - strip unwanted characters in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181208#M682729</link>
    <description>&lt;!--!*#--&gt;Hi Pault:&lt;BR /&gt;&lt;BR /&gt;Since this thread is really a continuation of your earlier thread here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1347151" target="_blank"&gt;http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1347151&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;...I'm going to build from it.  Using this as a test file:&lt;BR /&gt;&lt;BR /&gt;# cat testinput&lt;BR /&gt;Subject: =?ISO-8859-1?Q?Customer:_1111111,_Customer_PO:_123456789,_Order:_161318(?=&lt;BR /&gt;=?ISO-8859-1?Q?Added_lines_43)__06-12-2?=&lt;BR /&gt;To: me&lt;BR /&gt;&lt;BR /&gt;...your amended script might look like:&lt;BR /&gt;&lt;BR /&gt;# cat ./mymail&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $line, $subject );&lt;BR /&gt;my @now = localtime();&lt;BR /&gt;my $timestamp = sprintf("%04d-%02d-%02d",$now[5]+1900, $now[4]+1, $now[3]);&lt;BR /&gt;my $OUTPUT = "home/share/acks/order_acks_$timestamp.txt";&lt;BR /&gt;#-&amp;gt;open (OUTFIL, "&amp;gt;&amp;gt;$OUTPUT") || die "Cannot open $OUTPUT file";&lt;BR /&gt;{&lt;BR /&gt;    local $/=undef;&lt;BR /&gt;    while ($line=&amp;lt;&amp;gt;) {&lt;BR /&gt;        chomp $line;&lt;BR /&gt;        if ( $line =~ /( ^To:.*? )( [Cc]c:|Message-ID )/xms ) {&lt;BR /&gt;            print        $1, "\n";&lt;BR /&gt;        }&lt;BR /&gt;        if ( $line =~ /( ^[Cc]c:.*? )( Message-ID )/xms ) {&lt;BR /&gt;            print        "$line \n";&lt;BR /&gt;        }&lt;BR /&gt;        if ( $line =~ /( ^Subject:.*? )( To: )/xms ) {&lt;BR /&gt;            ( $subject = $1 ) =~ s/\Q=?ISO-8859-1?Q?\E//gxms;&lt;BR /&gt;            print "$subject\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;close OUTFIL;&lt;BR /&gt;exit;&lt;BR /&gt;&lt;BR /&gt;...which yields:&lt;BR /&gt;&lt;BR /&gt;# ./mymail testinput&lt;BR /&gt;Subject: Customer:_1111111,_Customer_PO:_123456789,_Order:_161318(?=&lt;BR /&gt;Added_lines_43)__06-12-2?=&lt;BR /&gt;&lt;BR /&gt;I left the original logic to extract the contents of the whole subject.  Then, since the string you wanted to remove occurred in several places I chose to substitute it for a null string (globally) rather than complicate the match expression and snip multiple pieces.  Since the string in question has regular expression metacharacters in it, I escaped the string with '\Q...\E'.  Once the $subject is collected and cleaned up we print it.&lt;BR /&gt;&lt;BR /&gt;Once again, for ease of debugging, I let output go to STDOUT.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
    <pubDate>Fri, 12 Jun 2009 23:00:01 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2009-06-12T23:00:01Z</dc:date>
    <item>
      <title>Perl Help - strip unwanted characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181207#M682728</link>
      <description>Hi All,&lt;BR /&gt;I have a Perl script with the following line:&lt;BR /&gt;&lt;BR /&gt;if ( $line =~ /( ^Subject:.*? )( To: )/xms ) {&lt;BR /&gt;            print OUTFIL $1, "\n";&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;WHich grabs the subject line of an email and writes it to a file.&lt;BR /&gt;&lt;BR /&gt;I have a charset statement in the subject line in 2 - 3 places that I want to strip out&lt;BR /&gt;&lt;BR /&gt;Subject line looks like: &lt;BR /&gt;Subject: =?ISO-8859-1?Q?Customer:_1111111,_Customer_PO:_123456789,_Order:_161318(?=&lt;BR /&gt; =?ISO-8859-1?Q?Added_lines_43)__06-12-2?=&lt;BR /&gt;&lt;BR /&gt;How do I strip out the "=?ISO-8859-1?Q?" from the line?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;Paul&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Jun 2009 22:24:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181207#M682728</guid>
      <dc:creator>Paul D. Simpson</dc:creator>
      <dc:date>2009-06-12T22:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Help - strip unwanted characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181208#M682729</link>
      <description>&lt;!--!*#--&gt;Hi Pault:&lt;BR /&gt;&lt;BR /&gt;Since this thread is really a continuation of your earlier thread here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1347151" target="_blank"&gt;http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1347151&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;...I'm going to build from it.  Using this as a test file:&lt;BR /&gt;&lt;BR /&gt;# cat testinput&lt;BR /&gt;Subject: =?ISO-8859-1?Q?Customer:_1111111,_Customer_PO:_123456789,_Order:_161318(?=&lt;BR /&gt;=?ISO-8859-1?Q?Added_lines_43)__06-12-2?=&lt;BR /&gt;To: me&lt;BR /&gt;&lt;BR /&gt;...your amended script might look like:&lt;BR /&gt;&lt;BR /&gt;# cat ./mymail&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ( $line, $subject );&lt;BR /&gt;my @now = localtime();&lt;BR /&gt;my $timestamp = sprintf("%04d-%02d-%02d",$now[5]+1900, $now[4]+1, $now[3]);&lt;BR /&gt;my $OUTPUT = "home/share/acks/order_acks_$timestamp.txt";&lt;BR /&gt;#-&amp;gt;open (OUTFIL, "&amp;gt;&amp;gt;$OUTPUT") || die "Cannot open $OUTPUT file";&lt;BR /&gt;{&lt;BR /&gt;    local $/=undef;&lt;BR /&gt;    while ($line=&amp;lt;&amp;gt;) {&lt;BR /&gt;        chomp $line;&lt;BR /&gt;        if ( $line =~ /( ^To:.*? )( [Cc]c:|Message-ID )/xms ) {&lt;BR /&gt;            print        $1, "\n";&lt;BR /&gt;        }&lt;BR /&gt;        if ( $line =~ /( ^[Cc]c:.*? )( Message-ID )/xms ) {&lt;BR /&gt;            print        "$line \n";&lt;BR /&gt;        }&lt;BR /&gt;        if ( $line =~ /( ^Subject:.*? )( To: )/xms ) {&lt;BR /&gt;            ( $subject = $1 ) =~ s/\Q=?ISO-8859-1?Q?\E//gxms;&lt;BR /&gt;            print "$subject\n";&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;close OUTFIL;&lt;BR /&gt;exit;&lt;BR /&gt;&lt;BR /&gt;...which yields:&lt;BR /&gt;&lt;BR /&gt;# ./mymail testinput&lt;BR /&gt;Subject: Customer:_1111111,_Customer_PO:_123456789,_Order:_161318(?=&lt;BR /&gt;Added_lines_43)__06-12-2?=&lt;BR /&gt;&lt;BR /&gt;I left the original logic to extract the contents of the whole subject.  Then, since the string you wanted to remove occurred in several places I chose to substitute it for a null string (globally) rather than complicate the match expression and snip multiple pieces.  Since the string in question has regular expression metacharacters in it, I escaped the string with '\Q...\E'.  Once the $subject is collected and cleaned up we print it.&lt;BR /&gt;&lt;BR /&gt;Once again, for ease of debugging, I let output go to STDOUT.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Jun 2009 23:00:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181208#M682729</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-06-12T23:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Help - strip unwanted characters</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181209#M682730</link>
      <description>&lt;!--!*#--&gt;James... thanks again! Works perfectly.&lt;BR /&gt;Paul</description>
      <pubDate>Sat, 13 Jun 2009 01:09:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-strip-unwanted-characters/m-p/5181209#M682730</guid>
      <dc:creator>Paul D. Simpson</dc:creator>
      <dc:date>2009-06-13T01:09:10Z</dc:date>
    </item>
  </channel>
</rss>

