#!/usr/bin/perl # http://perlmonks.org/?node_id=1176775 use strict; use warnings; print /x(.*)x(??{$1 =~ tr##.#cr})x/ ? 'pass' : 'fail', ' ', $_ while ; __DATA__ xxxxx x1x2x...x xxx x.x.x x12x..x x123x...x x123x.x.x x12x1x