One way..
#! perl -w use strict; my @colors = ( [167,45,37,56,65,67,56,78,231,35,142,20,187,137,19,107 +,117,127,137], # ... [221,245,237,0,0,0,0,0,235,235,145,220,218,146,194,46,133, +127,45,32] # ... ); # open DATA, '<g3.svg.tmpl' or die $!; #open OUT, '>g3.svg' or die $!; local $" = ','; # localise $" ($LIST_SEPAR +ATOR) and set it to be a comma # interpolate the arrays into matching lines s/^var colors(\d+) = \[\];/var colors$1 = "[@{ $colors[$1 - 1] }]";/ + and print # OUT # and print +it if it matched or print #OUT # otherwise ju +st print them while <DATA>; #close DATA or warn $!' #close OUT or warn $!' =pod Output C:\test>192405 <?xml version="1.0" standalone="no" ?> <!-- Created by "Barry Griffin" --> <!-- (C) Barry Griffin 2002 --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg id="mainmap" xml:space="preserve" style="shape-rendering:geometri +cPrecision; text- rendering:geometricPrecision; image-rendering:optimizeQuality" onload="init(evt)" width="800" height="420"> <script type="text/ecmascript"> <![CDATA[ var colors1 = "[167,45,37,56,65,67,56,78,231,35,142,20,187,137,19,107, +117,127,137]"; var colors2 = "[221,245,237,0,0,0,0,0,235,235,145,220,218,146,194,46,1 +33,127,45,32]"; REST OF DOC... C:\test> =cut __DATA__ <?xml version="1.0" standalone="no" ?> <!-- Created by "Barry Griffin" --> <!-- (C) Barry Griffin 2002 --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg id="mainmap" xml:space="preserve" style="shape-rendering:geometri +cPrecision; text- rendering:geometricPrecision; image-rendering:optimizeQuality" onload="init(evt)" width="800" height="420"> <script type="text/ecmascript"> <![CDATA[ var colors1 = []; var colors2 = []; REST OF DOC...
In reply to Re: Parsing a 100K doc
by BrowserUk
in thread Parsing a 100K doc
by Baz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |