my $s= 'the quick brown fox jumps over the lazy dog'; $$_ ne ' ' and $$_ = 'X' for map{ \substr( $s,$_, 1 ) } 0 .. length $s; print $s; XXX XXXXX XXXXX XXX XXXXX XXXX XXX XXXX XXXX