texuser74 has asked for the wisdom of the Perl Monks concerning the following question:
With the following code i have written, my output.txt contains just the text ‘1’.input.txt This is an example section. And the second line has structural science. jabb.txt eg <tab> example exp <tab> expand sect <tab> section sci <tab> science output.txt (required output) This is an eg sect. And the second line has structural sci.
please help me in correcting this script.use strict; use warnings; open( ABB, '<', 'jabb.txt' ) or die "Couldn't open ABB.\n$!"; open( IN, '<', 'input.txt' ) or die "Couldn't open infile.\n$!"; open( OUT, '>', 'output.out' ) or die "Couldn't open outfile.\n$!"; my @myin = <IN>; while(<ABB>){ if(/(.*?)\t(.*?)\n/){ my $abb=$1; my $full=$2; print "@myin\n"; @myin = s/$full/$abb/g; } } print OUT "@myin\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find and replace
by Corion (Patriarch) on Nov 04, 2005 at 07:43 UTC | |
by texuser74 (Monk) on Nov 04, 2005 at 07:54 UTC | |
|
Re: find and replace
by Zaxo (Archbishop) on Nov 04, 2005 at 09:02 UTC | |
|
Re: find and replace
by Skeeve (Parson) on Nov 04, 2005 at 08:47 UTC | |
|
Re: find and replace
by l.frankline (Hermit) on Nov 04, 2005 at 09:41 UTC | |
|
Re: find and replace
by radiantmatrix (Parson) on Nov 04, 2005 at 15:06 UTC | |
by benizi (Hermit) on Nov 04, 2005 at 19:23 UTC |