#! /usr/bin/perl use strict; use warnings; my $xml = < 1 xxx 2 xxx 3 EOF my @matches = $xml =~ m{(.*?)}mg; print "@matches\n";