dra2pac has asked for the wisdom of the Perl Monks concerning the following question:
The result shows me I am no way near what I need. Thank you in advance for any suggestions.$DOC1="1.txt"; $DOC2="2.txt"; open (DOC1,$DOC1); @words1=<DOC1>; close (DOC1); open (DOC2,$DOC2); @lines2=<DOC2>; close (DOC2); foreach $line2(@lines2) { @words2=split / /, $line2; foreach $word2(@words2) { s/$word2/$words1[0]/; splice (@words1, 0, 1); } print @words2; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replacing while keeping the position of the element in the file
by Roy Johnson (Monsignor) on Jul 27, 2004 at 14:17 UTC | |
|
Re: replacing while keeping the position of the element in the file
by Jasper (Chaplain) on Jul 27, 2004 at 14:48 UTC | |
|
Re: replacing while keeping the position of the element in the file
by TrekNoid (Pilgrim) on Jul 27, 2004 at 16:16 UTC | |
|
Re: replacing while keeping the position of the element in the file
by husker (Chaplain) on Jul 27, 2004 at 14:26 UTC | |
|
Re: replacing while keeping the position of the element in the file
by Art_XIV (Hermit) on Jul 27, 2004 at 15:13 UTC |