#! 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' or die $!; local $" = ','; # localise $" ($LIST_SEPARATOR) 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 just print them while ; #close DATA or warn $!' #close OUT or warn $!' =pod Output C:\test>192405