CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Perl Query


Suresh Kumar R

Mar 13, 2000, 4:33 AM

Post #1 of 1 (2205 views)
Perl Query Can't Post

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

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
3 $/='';
4 $^I='.old';
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)
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.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives