Hello, I just want to substitute the space to 0. Spaces were separated by tab. Thanks in advance! For example
1 2 2 5 4 4 4 4 4 3 4 4 1 1 5 6 4 change to 1 2 0 0 2 0 5 0 0 0 4 4 4 4 0 0 4 0 0 0 3 0 0 0 4 4 0 0 1 0 0 0 0 0 1 5 6 0 4 0 0 0 0 0
#use strict #use warning open(IN1, "tmp01") || die "Cannot open this file"; @lines = <IN1>; $i = 0; for (@lines) { $lines[$i]=~s/\s\s+/\t0\t/g; $thislines[$i]=$lines[$i]; print $thislines[$i]; $i++; } open(OUT, ">tmp02") || die "Cannot open this file"; for $thisline(@thislines){ print OUT $thisline;} close(OUT); close(IN1);
In reply to substitute space to 0 by yueli711
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |