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 making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-11-28 15:18 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (743 votes), past polls