I think this gets close to what your looking for

#! perl -slw use strict; my (@blocks, $datavertex); # Build the structure while(my $in = <DATA>) { if ( $in =~ /^88888/ ) { push @blocks, $datavertex; $datavertex = []; next; } my @vertex = ($in, scalar <DATA>, scalar <DATA>, 0); chomp @vertex; push @{$datavertex}, \@vertex; } push @blocks, $datavertex if @$datavertex; #! push the last block # Accessing it for my $block (0..$#blocks) { for my $dv ( 0 .. $#{$blocks[$block]} ) { for my $vertex ( 0 .. $#{$blocks[$block][$dv]} ) { print"[$block][$dv][$vertex] =>", $blocks[$block][$dv][$ve +rtex]; } print ''; } } __DATA__ 1 786.582394 1480.624270 2 877.141985 1284.635536 3 779.147607 1239.355735 4 688.588015 1435.344469 5 786.582394 1480.624270 88888 6 664.833374 241.139500 7 661.222659 245.226628

The output

22:44:50.88 C:\test>233619.pl [0][0][0] =>1 [0][0][1] =>786.582394 [0][0][2] =>1480.624270 [0][0][3] =>0 [0][1][0] =>2 [0][1][1] =>877.141985 [0][1][2] =>1284.635536 [0][1][3] =>0 [0][2][0] =>3 [0][2][1] =>779.147607 [0][2][2] =>1239.355735 [0][2][3] =>0 [0][3][0] =>4 [0][3][1] =>688.588015 [0][3][2] =>1435.344469 [0][3][3] =>0 [0][4][0] =>5 [0][4][1] =>786.582394 [0][4][2] =>1480.624270 [0][4][3] =>0 [1][0][0] =>6 [1][0][1] =>664.833374 [1][0][2] =>241.139500 [1][0][3] =>0 [1][1][0] =>7 [1][1][1] =>661.222659 [1][1][2] =>245.226628 [1][1][3] =>0

Examine what is said, not who speaks.

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


In reply to Re: 3D arrays, again by BrowserUk
in thread 3D arrays, again by stu96art

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.