Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Formatting outp...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 11005 of 11065
Post > Topic >>

Formatting output after search and replace

by sreevidhyas@[EMAIL PROTECTED] (Melody) Apr 29, 2008 at 03:06 PM

I have 2 files one has the input and the other has data that will
replace specific string in file 1

eg
----

File 1
---------
Text| to be replaced
Text| to be replaced
Text| to be replaced
Text| to be replaced
Text| to be replaced

File 2
---------
replaced1
replaced2
replaced3

Output
----------
Text|replaced
Text|replaced
Text|replaced
Text|replaced
Text|replaced

I have a pgm that works but the output looks like

text|replaced1

text|replaced2

text|replaced3
text|replaced1

text|replaced2

Here is the code
--------------------------

#!/usr/bin/perl
use warnings;
use strict;

my @[EMAIL PROTECTED]
 @[EMAIL PROTECTED]
 FHR,'<',"repl.txt";
open OUT,'>>',"output.txt";
open IN,'<',"input.txt";
@[EMAIL PROTECTED]
>;
@[EMAIL PROTECTED]
>;

for my $i(0..$#array)
{
 $array[$i]=~s/to be replaced/$replacearray[0]/gi;
 push @[EMAIL PROTECTED]
 shift @[EMAIL PROTECTED]
 @[EMAIL PROTECTED]
(/[^\$]/,@[EMAIL PROTECTED]
);
print OUT @[EMAIL PROTECTED]
 anyone point out to me what i am doing wrong??Thanks




 2 Posts in Topic:
Formatting output after search and replace
sreevidhyas@[EMAIL PROTEC  2008-04-29 15:06:48 
Re: Formatting output after search and replace
chas.owens@[EMAIL PROTECT  2008-04-30 01:57:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 0:22:31 CDT 2008.