in reply to build array of geometry data

If your files get very large, then slurping them into memory to parse can be memory intensive. This solution processes the file line-by-line and uses a running buffer to parse it.

Code

#! perl -slw use strict; my @arrays; my $buf =''; while($buf .= <DATA>) { push(@arrays, [ split(' ',$1) ]) , $buf = $2 while $buf =~ /\[([^]]+)\](.*$)/g; } print do{ local $"=','; "[@$_]" } for @arrays; __DATA__ [1 1 1 1 1 1] [4 4 4 4 4 4] [ 123 123 123 123 123 123 123 123 123 ] "P" [ -1 1 1 1 1 -1 1 1 1 ]

Output

<
c:\test>234118 [1,1,1,1,1,1] [4,4,4,4,4,4] [123,123,123,123,123,123,123,123,123] [-1,1,1,1,1,-1,1,1,1]

Examine what is said, not who speaks.

The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.