cron - perl search replace is appending not replacing -


i have perl script in cron runs every x minutes. suppose find string , replace string more data:

s/remote_phonebook.data.1.name =/remote_phonebook.data.1.name = users/; 

i expect this:

before:

remote_phonebook.data.1.name = 

after:

remote_phonebook.data.1.name = users 

the first time runs works fine. however, each additional time appends end of line 3 cron jobs later see:

 remote_phonebook.data.1.name = users users users 

how can make if "users" doesn't exist, add it, if exists, ignore?

if each 1 of these new line try:

$s =~ s/remote_phonebook\.data\.1\.name =( users|$)/remote_phonebook.data.1.name = users/; 

if not, please let me know on comments.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -