while (<DATA>) { s/ (?=.*\s?-1 )/,/g; print; } __DATA__ 01 fines name 2222 -P sws -1 reee.tee rrt 02 fi si 2232 -P sqww -1 re.wqw ttf 02 fi si-1 2232 -P sqww -1 re.wqw ttf
This will replace spaces with commas before the last -1 in the file.
In reply to Re: perl substitue till found pattern in aline
by rjt
in thread perl substitue till found pattern in aline
by Vijay81
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |