$s = 'fred_bill_john_jack_joe_mary_eugene';; $s =~ /(^[^_]+_[^_]+_[^_]+_)/ and print "'$1'";; 'fred_bill_john_'