![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl question regarding [ ] | hankooknara | Shell Programming and Scripting | 2 | 07-01-2007 01:21 PM |
| perl question | BG_JrAdmin | Shell Programming and Scripting | 1 | 09-09-2005 04:46 PM |
| Perl Question | Gary Dunn | Shell Programming and Scripting | 2 | 12-03-2004 09:37 AM |
| PERL question | frank | Shell Programming and Scripting | 1 | 06-18-2002 12:13 AM |
| Perl question | Jubba | Shell Programming and Scripting | 1 | 04-01-2002 11:24 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
PERL question
im trying to retrieve text in between <title> tags of a tagged document, store the text in a temporary file, feed that file into a porter stemmer program, capture the stemmer's output by piping it into an output file, then reconstructing the original tagged document but with the text in <title></title> stemmed.
my problem is that it doesn't run as i expect it to run. im suspecting that its either the system"" call that's at fault or the temp file themselves.. any help would be greatly appreciated! thanks! here's the code snippet... Code:
# read through the tagged document
while (<TOPIC_ORIG>) {
if (/<title>(.+?)<\/title>/) {
print TOPIC_TEMP "<title>";
# file to store text between <title> tags prior to stemming
$INFILE = ">$HOME/bin/stem.in";
open INFILE or die;
# file to store output of stemmer
$OUTFILE = ">$HOME/bin/stem.out";
open OUTFILE or die;
# store pre-processed text in stem.in
print INFILE "$1";
# run stemmer
system "$HOME/bin/porter-stemmer $HOME/bin/stem.in > $HOME/bin/stem.out";
# retrieve stemmed text in output file, write to TOPIC_TEMP
# between title tags.
while (<OUTFILE>) {
print TOPIC_TEMP;
}
# print end-tag
print TOPIC_TEMP "</title>";
# close temp files
close INFILE;
close OUTFILE;
} else {
#output all other tags and contents
print TOPIC_TEMP;
}
}
close TOPIC_ORIG;
close TOPIC_TEMP;
Code:
<doc> <title>some title</title> .......... </doc> |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Just looking at the code it looks like your handle for input is directed for output. $INFILE = ">$HOME/bin/stem.in";
|
|||
| Google The UNIX and Linux Forums |