in reply to Parsing with RegEx into Array

I understand you asked for a regex, but this kinda looks like XML, so here's an XML::Twig parser solution:
use strict; use warnings; use Data::Dumper; use XML::Twig; my $xfile = <<EOF; <foo> <item><i>headline 1</i></item> <item><i>headline2</i></item> </foo> EOF my $t = new XML::Twig(); $t->parse($xfile); my @x; for my $item ($t->root()->children('item')) { push @x, $item->first_child('i')->text(); } print Dumper(\@x); __END__ $VAR1 = [ 'headline 1', 'headline2' ];

Replies are listed 'Best First'.
Re^2: Parsing with RegEx into Array
by mr_p (Scribe) on Jun 25, 2010 at 18:27 UTC
    XML::Twig gave me problems loading it. Here is the error
    Parsing of undecoded UTF-8 will give garbage when decoding entities at + /usr/lib/perl5/vendor_perl/5.8.8/XML/Twig.pm line 731