Hello, tybalt89, Thank you so much for your great help.
The data file is
1 2 2 5 4 4 4 4 4 3 4 4 1 1 5 6 4
It comes out
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( <DATA> ) { s/(^| \K)(?!\d)/0/g; print; }
In reply to Re^2: substitute space to 0
by yueli711
in thread substitute space to 0
by yueli711
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |