Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Modifying File in the Middle

by kiruthika.bkite (Scribe)
on Apr 12, 2010 at 04:00 UTC ( #834179=note: print w/ replies, xml ) Need Help??

in reply to Modifying File in the Middle

Try with the following.

use Tie::File; use Fcntl 'O_RDONLY','O_RDWR'; my @file1; my @file2; my $file1; tie @file1, 'Tie::File', "fileA",mode => O_RDONLY; tie @file2, 'Tie::File', "fileB",mode => O_RDWR; $file1=join("\n",@file1); for($i=0;$i<=$#file2;$i++) { next unless($file2[$i]=~s/(SEARCHPATTERN)/$1\n$file1/) }
fileA<br> 1 2 3 4 5 fileB a b c d SEARCHPATTERN e f g h i Ouput(fileB) a b c d SEARCHPATTERN 1 2 3 4 5 e f g h i

Comment on Re: Modifying File in the Middle
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://834179]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2015-07-28 22:40 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (260 votes), past polls