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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.