Question : Delete a line in a text file using c program/perl script + system call

Hi,
I need to execute a perl script from a c program. so I presume I have to use System call. I need to pass 2 arguments to the perl script.
Arg1: filename
Arg2: string

The script should search & delete  the line with the matching string.
It should return appropriate retVal back to the System code so that
the c program can check against it.

A functioning code snippet will be helpful since I am not much
fimiliar with perl.

Also is there any way to do this in C without creating a new file.

Thanks in advance for help and feedback.

Answer : Delete a line in a text file using c program/perl script + system call

If you use a an alphanumeric character for #
you also need a space
 sprintf(cmd,"perl -i -pe '$ret+=s Z.*\\Q%s\\E.*ZZs;END{exit $ret}' %s", string, filename);

If "DiscoveryAddress=10.17.235.127:3260" is the filename
then there also seems to be a space missing before the last %s
Random Solutions  
 
programming4us programming4us