Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: replace first occurance if it doesn't already match

by toolic (Bishop)
on Mar 10, 2017 at 16:26 UTC ( #1184185=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re^2: replace first occurance if it doesn't already match
by ddrew78 (Beadle) on Mar 10, 2017 at 16:32 UTC
    Worked like a champ. Very much appreciated.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1184185]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2022-01-21 18:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?