#!/usr/bin/perl use strict; use warnings; my $cnt; while() { $cnt++; print "$cnt line\n"; s/(\d),(?=\d)/$1|$2/g; print; } __DATA__ work with 19,43 or so 14,99 we have, at most, 14,23 to do though some say it is 18,44 Without digits, all the , will remain. With digits 9, Ah ha! or With,3 no change for a 2nd line But again 3,4,5,6 all have bars.