http://qs1969.pair.com?node_id=1184185


in reply to replace first occurance if it doesn't already match

This works on the input you provided. It looks for the 1st digit followed by an underscore and replaces _ with :. Refer to s///
use warnings; use strict; while (<DATA>) { s/(\d)_/$1:/; print; } __DATA__ V12345:name_test V12345_name_test