#!/usr/bin/perl my $str = "headline 1 < item>headline2"; my @x =~ /<(.+?)>.+<\/\1>/ for $str;