Your data looks rather like it may be XML, in which case you may be better to look at some of the XML modules such as XML::Twig and XML::TreeBuilder. As an example of how these things can help consider:
#! /bin/perl -w use strict; use warnings; use XML::TreeBuilder; my $root = XML::TreeBuilder->new (); $root->parse (do {local $/; <DATA>;}); my $frame_marker = 'data'; my @dataNodes = $root->look_down ('_tag', 'data'); my $nodeCount; for my $nodeIndex (0 .. @dataNodes - 1) { my @strings = $dataNodes[$nodeIndex]->look_down ('_tag', 'string') +; print "Data node " . ($nodeIndex + 1) . "\n"; print " ", $_->as_text (), "\n" for @strings; } __DATA__ <root> <data> <string>1 some stuff</string> <string>1 some more stuff</string> <string>1 yet more stuff</string> <string>1 enough stuff</string> </data> <data> <string>2 some stuff</string> <string>2 some more stuff</string> <string>2 yet more stuff</string> <string>2 enough stuff</string> </data> <data> <string>3 some stuff</string> <string>3 some more stuff</string> <string>3 yet more stuff</string> <string>3 enough stuff</string> </data> </root>
Prints:
Data node 1 1 some stuff 1 some more stuff 1 yet more stuff 1 enough stuff Data node 2 2 some stuff 2 some more stuff 2 yet more stuff 2 enough stuff Data node 3 3 some stuff 3 some more stuff 3 yet more stuff 3 enough stuff
In reply to Re: Premature End-of-File - Scope problems?
by GrandFather
in thread Premature End-of-File - Scope problems?
by bratwiz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |