I want to thank everyone for helping me, but I am still having trouble. I am trying to get data from a file, like the one below. The 88888 marker means the end of a block. What I am trying to do is have a list of blocks which contain a list of vertices, which contains four elements. I am a little confused on how to read the vertices into the array when I don't know how many there are until I read the file. I apologize if I am repeating myself, but I am still confused. I am using a two dimensional array now and below the data is the code I use to get that.
Could I do something like
$Block[0] = @datavertex[0];? SO that I can have
$Block[0][0][1]
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
VERTEX: while ($line1 = <FHV>) {
if ($line1 == $ek) {
# print "BLOCK END\n";
$line1 = <FHV>;
if ($line1 = eof) {
last VERTEX;
}
}
my @vertex = (
scalar($line1),
scalar(<FHV>),
scalar(<FHV>),
scalar(0) );
$vertexcount = $vertexcount + 1;
chomp @vertex;
push @datavertex, \ @vertex;
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.