Mind the question mark in the regext to make it non-greedy:
However, i wonder why you didn't search, this question is answered before.
(Re^3: Pattern matching, How will my regular expression match?, Re: Regexp help, multiple lines )
Woops! Now it's my fault, i did not read properly, i'll be back with anorher answer...
*** Update ***
ok, final answer with one regexp...
#!/usr/bin/perl -w
use strict;
my $test="<root><ta>this is <ta>the sample <ta>text</ta> explanation</
+ta> needded</ta></root>";
my @data;
while ($test =~ m/(<ta>(.*)<\/ta>)/gs) {
unshift (@data,$1);
($test) = $2;
}
foreach (@data) {
print $_."\n";
}