$/ = undef; while (<>) { print "\n$ARGV\n", / (.+?) ^.*^ (.+?) \z/xms }