#!/usr/bin/perl -w use strict; while(<>) { s/(.*?)(....)$/("X" x length($1)).$2/e; print; }