use strict; use warnings; print m/^.*?(\w+\.\w+)$/ while(); __DATA__ shopping.yahoo.com yahoo.com some.very.long.url.at.yahoo.com #### $ perl -l 632539.pl yahoo.com yahoo.com yahoo.com