Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

related to QnC: A perl script that extracts QnC phrases from a file

0 views
Skip to first unread message

Kev the Dark Lord

unread,
Feb 14, 2002, 5:28:40 PM2/14/02
to
Hello,
This is just a little perl script that extracts QnC (quote and context) phrases
from at least one file.
Please note that I am
+ not a perl wizard
+ neither write bugfree software

anyway, have fun!

--cut--
#!/usr/bin/perl
####################################################################
## quotes.pl - extracting Question and Context phrases from texts ##
## reads quotes from a file and writes them to STDOUT ##
## 2002 by Benjamin S Wiegele <kevi at freeshell dot org> ##
####################################################################

unless (@ARGV)
{
die "Syntax: $0 file [file2] [...]\n";
}

foreach $file (@ARGV)
{
open (FILE, $file) || die "Could not open $file: $!\n";

print '-' x 80 . "\n" . "From $file: \n" . '_' x 80;
while ( <FILE> )
{
# filter greater-thans, as they may appear in eMails an USENET postings.
# Note: we don't remove leading spaces for now.

$_ =~ s/\>//g;

if ( /_QUOTE_/ )
{
print "Quote: \n";
while ( <FILE> )
{
last if $_ eq "_QUOTE_\n";
print "\t" . $_;
}
}

elsif ( /_CONTEXT_/ )
{
print "Context: \n";
while ( <FILE> )
{
last if $_ eq "_CONTEXT_\n";
print "\t" . $_;
}

print "\n";
}
}
}
--cut--

--
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++.[-]++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.

0 new messages