<?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 Perl question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/2850400#M93451</link>
    <description>Alright I give up. I seriously need some help with this perl script. &lt;BR /&gt;&lt;BR /&gt;Firswt let me tell you what I want it to do. I have procmail rules that filter incoming emails based on keywords (commingly used in spam and porn spam) and it filters it to a mailbox which I then go and check. What I want is to look at the mailbox with this script and print the keyword that matched as well as the line in the email that matched. So far this is what I have:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;open( WORDLIST, "dirtywordlist.lst") or die( "Couldn't open word list: $!");&lt;BR /&gt;@list = &lt;WORDLIST&gt;;&lt;BR /&gt;close( WORDLIST ) or die( "Couldn't close word list: $!");&lt;BR /&gt; &lt;BR /&gt;open( EMAILFILE, "dirtytest") or die( "Couldn't open word list: $!");&lt;BR /&gt;@email = &lt;EMAILFILE&gt;; &lt;BR /&gt;close( EMAILFILE ) or die( "Couldn't close word list: $!");&lt;BR /&gt; &lt;BR /&gt;foreach( @list){&lt;BR /&gt;$matched = grep /$_/i, @email;&lt;BR /&gt;&lt;BR /&gt;if( $matched ){&lt;BR /&gt;print "$_\n";&lt;BR /&gt;print "$matched\n\n";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am fairly new to perl and would greatly appreciate any help that someone can lend. &lt;BR /&gt;&lt;BR /&gt;dirtywordlist.lst is the list of keywords to grep for and dirtytest is a test message I greated to see if the script is working correctly.&lt;BR /&gt;&lt;BR /&gt;When I run this it print every keyword for $_ and $matched prints as 3 for every keyword. The file only contains one word that should match.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for your help.&lt;/EMAILFILE&gt;&lt;/WORDLIST&gt;</description>
    <pubDate>Fri, 22 Nov 2002 18:30:43 GMT</pubDate>
    <dc:creator>Jeffrey S. Sims</dc:creator>
    <dc:date>2002-11-22T18:30:43Z</dc:date>
    <item>
      <title>Perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/2850400#M93451</link>
      <description>Alright I give up. I seriously need some help with this perl script. &lt;BR /&gt;&lt;BR /&gt;Firswt let me tell you what I want it to do. I have procmail rules that filter incoming emails based on keywords (commingly used in spam and porn spam) and it filters it to a mailbox which I then go and check. What I want is to look at the mailbox with this script and print the keyword that matched as well as the line in the email that matched. So far this is what I have:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;open( WORDLIST, "dirtywordlist.lst") or die( "Couldn't open word list: $!");&lt;BR /&gt;@list = &lt;WORDLIST&gt;;&lt;BR /&gt;close( WORDLIST ) or die( "Couldn't close word list: $!");&lt;BR /&gt; &lt;BR /&gt;open( EMAILFILE, "dirtytest") or die( "Couldn't open word list: $!");&lt;BR /&gt;@email = &lt;EMAILFILE&gt;; &lt;BR /&gt;close( EMAILFILE ) or die( "Couldn't close word list: $!");&lt;BR /&gt; &lt;BR /&gt;foreach( @list){&lt;BR /&gt;$matched = grep /$_/i, @email;&lt;BR /&gt;&lt;BR /&gt;if( $matched ){&lt;BR /&gt;print "$_\n";&lt;BR /&gt;print "$matched\n\n";&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am fairly new to perl and would greatly appreciate any help that someone can lend. &lt;BR /&gt;&lt;BR /&gt;dirtywordlist.lst is the list of keywords to grep for and dirtytest is a test message I greated to see if the script is working correctly.&lt;BR /&gt;&lt;BR /&gt;When I run this it print every keyword for $_ and $matched prints as 3 for every keyword. The file only contains one word that should match.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for your help.&lt;/EMAILFILE&gt;&lt;/WORDLIST&gt;</description>
      <pubDate>Fri, 22 Nov 2002 18:30:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/2850400#M93451</guid>
      <dc:creator>Jeffrey S. Sims</dc:creator>
      <dc:date>2002-11-22T18:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Perl question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/2850401#M93452</link>
      <description>Where's your chomp's? :) You are now matching *with* newlines. And for optimization of the process, use qr//&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;sub file2list ($)&lt;BR /&gt;{&lt;BR /&gt;my $file = shift;&lt;BR /&gt;open FILE, "&amp;lt; $file" or die "Couldn't open $file: $!");&lt;BR /&gt;chomp (@list = &lt;FILE&gt;);&lt;BR /&gt;close LIST or die "Couldn't close $file: $!");&lt;BR /&gt;@list;&lt;BR /&gt;} # sub2list&lt;BR /&gt;&lt;BR /&gt;my @list = map { qr/$_/i } file2list ("dirtywordlist.lst");&lt;BR /&gt;my @email = file2list ("dirtytest");&lt;BR /&gt;&lt;BR /&gt;foreach (@list) {&lt;BR /&gt;my $matched = grep /$_/, @email or next;&lt;BR /&gt;print "$_\n";&lt;BR /&gt;print "$matched\n\n";&lt;BR /&gt;}&lt;/FILE&gt;</description>
      <pubDate>Sat, 23 Nov 2002 09:38:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-question/m-p/2850401#M93452</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-11-23T09:38:18Z</dc:date>
    </item>
  </channel>
</rss>

