Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://834179]
help
Chatterbox?
[Corion]: Oh yay. The (external, not guided by me) programmers have chosen Moose+DBIx::Class for some implementation, and now seem to do 1+n SELECT statements for each row, as is usual when using ORMs.
[Corion]: So maybe I should investigate how to plug in a cache in front of DBIx::Class so I can do a ->selectall_hashre f and then satisfy the "sub"-selects from that cached single SELECT statement ...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-09-25 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (279 votes). Check out past polls.

    Notices?