Hi Guys,
thanks heaps for all your replies.
that helped me understand more of reg exp in perl, but I'm not quite there yet :(
Graff, you're right in saying the sample has a lot of whitespaces. I copied and pasted the format as is. so the while loop looks like it's the way to go.
the Coordinate field in vrml has thousands of those points where each set of 3 represents (x,y,z) coordinates.
A snippet of the code looks like
geometry IndexedFaceSet {
coord
Coordinate {
point [ 265.185 -166.225 -510.375,
264.529 -166.901 -513.43,
269.321 -166.425 -510.918,
271.021 -166.956 -513.279,
271.223 -167.21 -514.637,
272.77 -166.984 -514.019,
270.767 -167.555 -516.859,
268.668 -167.344 -515.143,
272.884 -167.285 -515.945,
266.267 -167.539 -516.835,
267.193 -167.766 -518.544,
272.686 -167.438 -517.418,
269.214 -167.83 -519.399,
274.761 -166.996 -515.928,
275.801 -166.946 -519.035,
264.372 -167.451 -517.076,
266.21 -167.785 -519.148,
263.801 -167.367 -516.587,
269.266 -167.919 -521.463,
271.322 -167.821 -522.477,
266.656 -168.197 -528.597,
269.644 -168.342 -527.906,
267.007 -167.981 -524.961,
264.07 -167.493 -517.639,
263.244 -167.65 -520.707,
267.726 -167.91 -521.09,
264.468 -167.739 -523.493]
}
This would give the coordinates for points defining one block.
The model has a number (around 30) of blocks within it, each with a Coordinate field.
and I need to read all the points from all the blocks.
I tried playing around with the few suggestions provided, but still does not have to right reg exp to match the format I am seeking.
what does colon (:) mean in ((?:\s*\d+){3})
I tried something like
while ( $array =~ /\[ #open sq bracket
((?:\s*\d+){3}) #match 3 numerics
,
((?:\s*\d+){3})
\]
/gx)
{
print "Grr: get inside this loop";
}
on a test sample where there were only 2 sets of (x,y,z) coordinates within sq brackets.
the print statement is not getting executed.
thanks again for your precious help!!:)
Phoenix.
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.