Skip to main content.
home | support | download

Back to List Archive

Re: Home-made FileFilter problem

From: Alan Ivey <ai4891(at)not-real.yahoo.com>
Date: Tue Aug 10 2004 - 14:08:03 GMT
> Can you run it like:
> 
>    ./gettxttitle.pl 1996-032.txt

I altered it so that it would just now and it works on
the command line. It generates the output that I need.
Here's the script (I know it's ridiculous but it does
exactly what I need it to do)...

#!/usr/bin/perl -w
open INPUT,$ARGV[0];

$Author="";
while($Author eq "") {
  $line = <INPUT>;
  if($line=~m/[A-Z,a-z]/) {
    $Author=$line;
    chomp $Author;
    last;
  } 
}

$Title="";
while($Title eq "") {
  $line = <INPUT>;
  if($line=~m/[A-Z,a-z]/) {
    if($line=~/^RELEASE: / || $line=~/^EDITORS NOTE:
/) {
      while($Title eq "") {
        $line = <INPUT>;
        if($line=~m/[A-Z,a-z]/) {
          $Title = $line;
          chomp $Title;
          $line = <INPUT>;
          if($line=~m/[A-Z,a-z]/) {
            $Title .= $line;
            chomp $Title;
          }
        }
      }
    }
  }
} 

@tempBody=<INPUT>;
$i=0;
while($i<=@tempBody) {
  $Body .= $tempBody[$i];
  $i++;
}

close INPUT;

# Print the results in HTML
print <<EOF;
<html>
<head>
<title>$Title</title>

<META NAME="Author" CONTENT="$Author">

</head>
<body>
<pre>
$Body</pre>
</body>
</html>
EOF

When I run...
$ perl gettxttitleC.pl 98-054.txt
I get the HTML that I want. When I plug it in SWISH-E.
I get...
Use of uninitialized value in pattern match (m//) at
/home/alan/ftpdownload/gettxttitleC.pl line 38,
<INPUT> line 39.
.. which means that my script isn't getting anything
from INPUT. I've changed $ARGV[0] to $1 and $2 as
stated in the docs
(http://www.swish-e.org/current/docs/SWISH-CONFIG.html#Filtering_with_the_FileFilter_feature)
but I get the same kind of error.

I don't think DirTree.pl would work because it uses
the SWISH::Filter, and this is only for 2 specified
folders containing txt files, not every txt file.

As always, thanks!
-Alan

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Received on Tue Aug 10 07:08:34 2004