Geeks Talk

Geeks Talk (http://www.geekinterview.com/talk/)
-   PERL (http://www.geekinterview.com/talk/perl/)
-   -   How to replace particular region only and print all content as a output file. (http://www.geekinterview.com/talk/7338-how-replace-particular-region-only-print.html)

vishwaRam 10-29-2007 02:59 AM

How to replace particular region only and print all content as a output file.
 
Hi all,

I want to replace a particular blocks only not in entire file. But I will give a new output file with replacement. Replacement should not affect other text



Code:

        my $table;
        if(m/<tb>(.*?)<\/tb>/msg)
            {
                $table = $&;
            }
 
        $table =~ s/\|/<\/ce><ce>/g;    #opening and closing cell
        $table =~ s/<ce>(.+)\n/<ce>$1<\/ce><\/r>\n/g; #for closing row
        $table =~ s/\n(.+)<\/ce>/\n<r><ce>$1<\/ce>/g; #for opening row
 
print OUTFILE $_; # Here is doubt how I can print entire text(output) including replcement text with order of text based on source.



Input file:

Some other text
<tb>
Het blijvend beeld der Hollandse Kunst|1
De Bijbel in Holland's Schilder-cultuur|25
</tb>
Some other text

Output file:

Some other text
<tb>
<r><ce>Het blijvend beeld der Hollandse Kunst</ce><ce>1</ce></r>
</tb>
Some other text

Thank in advance.
vishwa Ramkumar


All times are GMT -4. The time now is 05:39 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved