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
Post a Comment