Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

Hi,
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2014-07-30 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (240 votes), past polls