1 2 2 5 4 4 4 4 4 3 0 4 4 1 0 1 5 6 4 #!/usr/bin/perl # https://perlmonks.org/?node_id=1220510 use strict; use warnings; open(DATA,"DATA")||die"cannot open the file: $!\n"; while( ) { s/(^| \K)(?!\d)/0/g; print; }