[Memphis.pm] quotes in program arguments

Steve Lane sml at zfx.com
Tue Nov 12 11:20:21 CST 2002


Hal Phillips wrote:
> 
> Hey, does anyone know how to tell perl to interpret quotes in a program
> argument as just part of a string?  More precicely, I need something that
> basically will take the equivalant of echo's $* as a command argument.
> 
> What I neet to do is have a perl program that I can to this with:
> >program.pl -o [2002-11-12 09:00:00]: subject=SOMETEXT,
> message={SEVERITY="ERROR", ACTION="None", MOREKEYS="MOREVALUES", ETC="ETC
> ETC ETC"}
[snip]
> > program.pl -o Sam"I"am
> SamIam
> 
> what I need is Sam"I"am to actually make it through uninterpreted.

this has nothing to do with Perl; it's a shell question.
your shell acts on the double-quotes before they ever reach
perl.  the same would happen if you had any of [*?'><&] (etc)
in your argument.

just single-quote your argument:

$ echo Sam"I"am
SamIam
$ echo 'Sam"I"am'
Sam"I"am

if your argument has single-quotes, you'll have to escape them,
in your preferred way of shell-single-quote-escaping, such as:

$ echo 'Sam"I"a'"'"'m'
Sam"I"a'm

--
Steve Lane <sml at zfx.com>
----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------




More information about the Memphis-pm mailing list