#!/usr/local/bin/perl use strict; use warnings; my $text='(one dfd(two(three)four()(five)df())df)'; print $& if $text=~m#(.*)#;