my $indata; open( I, "<", "vrml.file" ) or die "vrml.file: $!"; { local $/; $indata = <>; } while ( $indata =~ /\[ # match open sq-bracket ((?:\s*\d+){3}) # match 3 numerics , # match comma ((?:\s*\d+){3}) # match 3 more numerics \] # match close sq-bracket /gx ) { my ( $x, $y ) = ( $1, $2 ); s/^\s+// for ( $x, $y ); my @x = split " ", $x; my @y = split " ", $y; # @x and @y each contain 3 numeric values my $axis = "x"; for my $aref ( \@x, \@y ) { print scalar @$aref, " elements in $axis array: @$aref\n"; $axis++; } }