in reply to Re: substitute space to 0
in thread substitute space to 0
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: substitute space to 0
by tybalt89 (Monsignor) on Aug 17, 2018 at 20:02 UTC |