thanks for the reply! just to clear things up: i have a about 1000 lines long html file where there occour a table with something like these table rows: <tr><td>ABC</td><td>111.09</td>222.00<td>333.89</td></tr> <tr><td>DEFG</td><td>444.44</td>555.67<td>nothing</td></tr> <tr><td>HIJ</td><td>666.99</td>empty<td>empty</td></tr> all the figures need to be replaced from a txt-file that will look like this when transformed and colon-seperated: ABC:777.77:888.88:999.99 DEFG:111.11:222.22 HIJ:666.66 so my new html-file (which should be a plain new html (or txt - it doesn really matter) file so i can compare it with the original)should look like: <tr><td>ABC</td><td>777.77</td>888.88<td>999.99</td></tr> <tr><td>DEFG</td><td>111.11:</td>222.22<td>nothing</td></tr> <tr><td>HIJ</td><td>666.66</td>empty<td>empty</td></tr> so there is a pattern for the replacement ... hope this clear things up i´m working on my own perl-construct but would still really like to see how it should be done thanks again allan >can anyone show me a very simple working example if i have >these two files: >thanks >allan > > >1.txt: > >hello >world >here is the old date >today is the 9th of july >more stuff > >2.txt: > >9 >10 >11 >12 > >i just need to know the basic procedure of how to get the figure "10" from >2.txt into the fourth line of 1.txt (so it reads: "today is the 10th of >july") I think I speak for everybody, if I say that your requirements are not clear at all. What do you want? How can we know that you want the "10" from the second file? How should we recognize the location to put the replacement in the first file? And do you want to replace the oruiginal contents of the first file, or do you want to print a modified version (e.g. send to browser), and leave the original file alone? If you want to replace the original file, try something like: #! perl -i.bak while(<>) { s/(\d+)/$1==9?'10':$1/ge; } But I think what you really want, is a template mechanism. There are already lots of template modules available on CPAN, but you can still roll your own. All you need is a recognizable pattern, from which you can extract a "variable" name, look it up in a hash, and replace the original thing with the value from the hash, in a s///g statement. -- Bart. ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org >can anyone show me a very simple working example if i have >these two files: >thanks >allan > > >1.txt: > >hello >world >here is the old date >today is the 9th of july >more stuff > >2.txt: > >9 >10 >11 >12 > >i just need to know the basic procedure of how to get the figure "10" from >2.txt into the fourth line of 1.txt (so it reads: "today is the 10th of >july") I think I speak for everybody, if I say that your requirements are not clear at all. What do you want? How can we know that you want the "10" from the second file? How should we recognize the location to put the replacement in the first file? And do you want to replace the oruiginal contents of the first file, or do you want to print a modified version (e.g. send to browser), and leave the original file alone? If you want to replace the original file, try something like: #! perl -i.bak while(<>) { s/(\d+)/$1==9?'10':$1/ge; } But I think what you really want, is a template mechanism. There are already lots of template modules available on CPAN, but you can still roll your own. All you need is a recognizable pattern, from which you can extract a "variable" name, look it up in a hash, and replace the original thing with the value from the hash, in a s///g statement. -- Bart. ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org