Hello: In message <3cf3c49bc1c50e439237fdf6dbd1678334fbb...@evcspmbx2.ads.northwestern .edu>, Michael J Rykowski writes: >I want to pass an entire line to a perl script if it matches a pattern, >but I would like to escape all quotation marks in that line. > >For example if the line is: > >Field1,field2,"field 3 is a string",field4 > >I want $0 to be: > >Field1,field2,\"field 3 is a string\",field4 > >What would be the best way to substitute " with \" for the following config? > >type=SingleWithSuppress >ptype=regexp >pattern=.*pattern to match.* >desc= $0 >action=shellcmd /home/test.pl "$0" >window=30
Is there some reason the perl script can't read the line from stdin so you can use: action=pipe '$0' | /home/test.pl rather then trying to pass it on the command line where it can be mangled/executed by the shell? (Btw using the shellcmd mechanism, for security you would also want to escape backquotes ` in the string as well as possibly single quotes. You never know what ends up in the data stream.) Also check out the --quoting flag to sec in the maan page: --quoting, --noquoting if the --quoting option is specified, operation description strings that are supplied to command lines of shellcmd and spawn actions will be put inside apostrophes. All apostrophes ' that strings originally contain will be masked. This option prevents the shell from interpreting special symbols that operation description strings might contain. Default is --noquoting. if you really really want to do what you say you want to do, I would suggest using lcall (or maybe calll) e.g. (untested): action= lcall %escaped $0 -> ( sub { return $_[0] ~ s/"/\\"/g } ); or something along those lines. Then pass "%escaped" to the shellcmd in place of $0. -- -- rouilj John Rouillard =========================================================================== My employers don't acknowledge my existence much less my opinions. ------------------------------------------------------------------------------ _______________________________________________ Simple-evcorr-users mailing list Simple-evcorr-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/simple-evcorr-users