$str =~ s!(fancy re here)! print "$1\n"; "" !ge;