
Suresh Kumar R
Deleted
Mar 13, 2000, 4:33 AM
Post #1 of 1
(589 views)
|
Hi, I am a person who checks quality of the outgoing SGML files in my organization. I have written a perl script, the script is very simple, it has to extract the tags from a file called "del_spc_bfr_afr". I am new to perl. The contents of the "del_spc_bfr_afr" file looks like this <TITLE> <P> <BOOK <ARTICLE> . . When i run this program for example ./pl1 test, on the target file test. The target file on the test looks like this. (Simply for testing purpose, some junk content) "<ARTICLE> <TITLE>This is a (test)) done by me {to chek (the occurence) the [ special characters ].</TITLE> <P> This program may (work may not work.</P> </ARTICLE>" After running the program the output was not replaced by what i was expecting. The out was looking like this "<ARTICLE> <TITLE>This is a (test)) done by me {to chek (the occurence) the [special characters ].</TITLE> <P> This program may (work may not work.</P> </ARTICLE>" 1 #!/usr/bin/perl -w 2 3 $/=''; 4 $^I='.old'; 5 6 open(FILE1, "<del_spc_bfr_afr") or die "Cannot open file $!"; 7 @bfrafr=<FILE1>; # storing the Tag contents into an array. 8 close(FILE1); # closing the file 9 chomp(@bfrafr); # removing the carriage return.(this one is not working i think) 10 11 while(<> ) 12 { 13 s/\s+/ /g; 14 s/(\[|\{|\()\s+/$1/g; 15 foreach $bfrafr(@bfrafr) 16 { 17 s/\s*($bfrafr)\s*/($bfrafr)/g; 18 } 19 print; 20 print STDOUT $_; 21 } I am not getting the required output, actually after running this program it has to replace space <TITLE> with without space <TITLE>. I have used chomp but it is not working, the carriage return is still there. If i store the same tag in a local variable and if i execute, the program works. I dont know what is happening. Please help me. Waiting for your reply. Regards,
|