[Memphis.pm] quotes in program arguments

Hal Phillips HPhillips at harrahs.com
Tue Nov 12 13:46:40 CST 2002


Hah!  The single quotes worked!  So, as long as I never encounter those in
the message body, I'm ok.

Thanks Steve!

-----Original Message-----
From: Hal Phillips 
Sent: Tuesday, November 12, 2002 1:39 PM
To: 'memphis-pm-list at pm.org'
Subject: RE: [Memphis.pm] quotes in program arguments


Hmmm,... I'll try the single quote thing.  Thanks for the tip.  It may work
as long as the incomming message has no single quotes,... unfortunately the
possibility is there and I cannot modify the message.  Yes, I agree it is a
shell issue and not a perl one specifically, however the shell is the
interface used to call the perl, it would be nice to have away around this
issue via an argument or switch...  It's interesting that if the message is
strictly STDIN, it works. i.e. >cat file_containing_message|program.pl

while(<STDIN>)
{
   @array = split //;
}

foreach $c (@array)
{
   if ( $c eq "\"" )
   {
      $c = "\\$c";
   }
   $newstring .= $c;
}
print $newstring;



-----Original Message-----
From: Steve Lane [mailto:sml at zfx.com]
Sent: Tuesday, November 12, 2002 11:58 AM
To: memphis-pm-list at pm.org
Subject: Re: [Memphis.pm] quotes in program arguments


Hal Phillips wrote:
> Thanks, but the problem is that I can't modify the incoming message before
I
> see it.

i don't understand why you can't just put single quotes around
the argument, but anyway... you're S-O-L then.  again, it's
the shell, not perl, that's the cause of your problem.

-- Steve

> -----Original Message-----
> From: Steve Lane [mailto:sml at zfx.com]
> Sent: Tuesday, November 12, 2002 11:20 AM
> To: memphis-pm-list at pm.org
> Subject: Re: [Memphis.pm] quotes in program arguments
> 
> 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.
>
----------------------------------------------------------------------------
> 
>
----------------------------------------------------------------------------
> To unsubscribe, please send email to majordomo at pm.org
> with 'unsubscribe memphis-pm-list' in the body of the message.
>
----------------------------------------------------------------------------

--
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.
----------------------------------------------------------------------------

----------------------------------------------------------------------------
To unsubscribe, please send email to majordomo at pm.org
with 'unsubscribe memphis-pm-list' in the body of the message.
----------------------------------------------------------------------------

----------------------------------------------------------------------------
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