ERROR IN SCRIPT 
Author Message
 ERROR IN SCRIPT

# This is day one for me and learning perl.  I seem to have  problem dealing
# with ".  I have the script working but it fails on some lines.  Namely I
# cannot effectively search for "text". I need to be able to make the "
# explicit but am failing.  I would appreciate any help.  thanks

# regards Rupert

$inputdir = "d:\\trade";
$outputdir = "d:\\trade";
$inputfile = "$inputdir\\contents.fff";
$outputfile = "$outputdir\\all_con2.txt";

open(INPUT, "<$inputfile") || die "could not open $inputfile\n";
open(OUTPUT, ">$outputfile") || die "could not open $outputfile\n";

#
## Sample lines  (I am trying to understand the syntax.)
#                      
#
# the words Tuamotu Islands should be copied infront of the <RD> tag
#               <RD><GR:"g europe"><GR:"g western europe"><GR:"e european
economic area"><GR:"e european union"><PS:IX>Tuamotu Islands(see
<QL:Query,"[Group C France:]",RH>France<EL>)
#
# the words "Ashmore Islands" should be copied infront of the <RD> tag
#               <RD><PS:"IX2">Ashmore Islands
#
# the word "Bahrain" should be copied infront of the <RD> tag
# I am not sure how to pick up "Bahrain" instead of the Middle East on this
line.  (please note that I am using perl 4 and cannot do minimal matching or
so I believe)
#               <RD><GR:"g asia"><GR:"g middle east"><PS:IX><QL:Query,"[Group
C Bahrain:]",RH>Bahrain<EL><TB><PW:Popup,3,0.5625><QL:Query,"[Group g middle
east:]",RH>Middle East<EL><LT>AS(ME)<EL>

#
# ATTEMPT 1
#while (<INPUT>) {
#       if      /(.*)\<PS\:IX\>(.*)\s\(see(.*)$/{
#               /$2$1<PS:IX> $2 $3/;
#       }else   /(.*)\<PS\:IX2\>(.*)$/{
#               /$2$1<PS:IX2> $2/;
#       }else   /(.*)\<PS\:IX\>\<(.*)\,RH\>(.*)\<EL\>(.*)/    {
#               /$3$1<PS:IX><$2,RH>$3<EL>$4/;
#       }
#       print OUTPUT;
#}
# did not even start due to syntax errors

# ATTEMPT 2
#while (<INPUT>) {
#       if      (/(.*)\<PS\:IX\>(.*)\s\(see(.*)$/) {                                      
#               s/^(.+)\<PS\:IX\>(.+)\s\(see(\<.+)$/$2$1<PS:IX> $2 $3/;                  
#       }elsif  (/(.*)\<PS\:IX2\>(.*)$/) {                                                
#               s//$2$1<PS:IX2> $2/;
#       }elsif  (/(.*)\<PS\:IX\>\<(.*)\,RH\>(.*)\<EL\>(.*)/)  {
#              
s/(.*)\<PS\:IX\>\<(.*)\,RH\>(.*)\<EL\>(.*)/$3$1<PS:IX><$2,RH>$3<EL>$4/;
#       }
#       print OUTPUT;
#}
# Works but skips the lines of type     <RD><PS:"IX2">Ashmore Islands  
# the script does not account for the "" around the IX2

# ATTEMPT 3
#while (<INPUT>) {
#       if      (/(.*)\<PS\:IX\>(.*)\s\(see(.*)$/) {                      
#               s/^(.+)\<PS\:IX\>(.+)\s\(see(\<.+)$/$2$1<PS:IX> $2 $3/;                  
#       }elsif  (/^(.+)\<PS\:\(.)IX2(.)\>(.+)$/) {                                        
# I tried to enter \" But this did not find the text it just stopped the prog.              
#               s//$4$1<PS:"IX2"> $2/;
#       }elsif  (/(.*)\<PS\:IX\>\<(.*)\,RH\>(.*)\<EL\>(.*)/)  {
#              
s/(.*)\<PS\:IX\>\<(.*)\,RH\>(.*)\<EL\>(.*)/$3$1<PS:IX><$2,RH>$3<EL>$4/;
#       }
#       print OUTPUT;
#}
# THIS ATTEMP GIVES NO OUTPUT

#ATTEMPT 4
while (<INPUT>) {
        s/^(.+)\<PS\:IX\>(.+)\s\(see(\<.+)$/$2$1<PS:IX> $2 $3/;                          
        s/^(.+)\<PS\:IX2\>([\w]+)$/$2$1<PS:IX2> $2/;                                                                        
        s/^(.+\>)([A-Z][a-z\s]+)\<EL\>(.+)$/$2$1<EL>$3/;                        
        print OUTPUT;

Quote:
}

#THE SECOND AND FOURTH ATTEMPS BOTH WORK ON THE FILE LEAVING ONLY THE LINES
WITH THE "IX2" EG. <RD><PS:"IX2">Ashmore Islands
# EG. RESULT SHOULD READ:
# Ashmore Islands<RD><PS:"IX2">Ashmore Islands


Fri, 20 Nov 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Error 500 - internal server error on scripts that work

2. server config error or script error?

3. mod_perl: Solved: Status<>200, apache mustn't display error message, script does

4. Error in script EOF

5. Show the error of script via Browser

6. Error in script

7. error in script-why?

8. Non-fatal error, "script not found or unable to stat"

9. 5.005 causes "to late for -T" errors in scripts

10. Hlp pls : "push" errors when scripts ported to Unix. (simple 2-d arrays)

 

 
Powered by phpBB® Forum Software