$x="/something/more words"; $x =~ m|<(\w+)>(.*)\1>|g; print "first is $1\n"; # You can put the <> around it here $2 =~ m|(/\w+/)(.*)| ; print "second is $1\n"; print "third is $2\n";