Apologies, no  regex being used here. Actu ally the question lies in why is the 
difference seen between when i use
$cmd_1 = "$prog -o $formatStr $queryStr";
and
$cmd_2 = "$prog -o \"%xxxx#%yyyy#%zzzzz\" $queryStr"; ## this is Ok.

In cmd 1 formatStr is equal to '"%xxxx#%yyyy#%zzzzz' (same as seen in cmd 2 
except here dbl quotes exists as it is), and the single quotes are necessary.

  Cheers.



--- On Thu, 12/11/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Subject: Re: escape some char
> To: [EMAIL PROTECTED]
> Date: Thursday, December 11, 2008, 5:03 PM
> hi --   
>  
> In a message dated 12/11/2008 6:06:45 A.M. Eastern Standard
> Time,  
> [EMAIL PROTECTED] writes:
>  
> > Hi,
> > 
> > Can someone pls shed me some  light>>
> > 
> > I have a func --
> > 
> > sub  get_formatStr {
> >   my $formatStr = 
> '"%xxxx#%yyyy#%zzzzz"';
> >   return  $formatStr;
> >   }
> > 
> > where in above, %xxx, %yyy  & %zzz are literals
> > & all three being delimeted by '#'
> >  and the combination should always be enclosed by
> double quotes.
> > 
> >  I have to use this string in a regex as below-
> >   $cmd = "$prog  -o $formatStr $queryStr";
> ## first $cmd
> > But this cribs in cmd execution  and o/p bangs!
> > However
> >   $cmd = "$prog -o 
> \"%lxxxx#%yyyy#%zzzzz\" $queryStr";
> ## second $cmd.
> > works fine &  supplies expected o/p.no issues with
> $queryStr too.
> > Now, problem arises  when I use the first $cmd.
> > Is there any way (built in funcs or tekniks)  where in
> I can
> > use the first $cmd and still get the good o/p as from 
> second $cmd ?
> > 
> > TIA
> 
> 
> i cannot see why the two strings should differ and hence
> why there should 
> be any difference in their effect.   
>  
> i suspect you are not showing all relevant code.   
>  
> try this and see if the two strings are indeed exactly
> equal:   
>  
> my $fs = formatStr();
> my $cmd_1 = "$prog -o $fs $queryStr";
> my $cmd_2 = "$prog -o
> \"%xxxx#%yyyy#%zzzzz\" $queryStr";
> $cmd_1 eq $cmd_1 or die ":$cmd_1: not really
> :$cmd_2:";
>  
> (btw -- although you do not show any such code, you mention
> using 
> the format string returned from the function formatStr() in
> a  regex.   
> are you aware that the '#' character is a
> 'comment-to-end-of-line' when 
> used in a regex with the regex //x switch?)   
>  
> hth -- bill walters   
>  
> 
> **************Make your life easier with all your friends,
> email, and 
> favorite sites in one place.  Try it now. 
> (http://www.aol.com/?optin=new-dp&icid=aolcom40vanity&ncid=emlcntaolcom00000010)


      

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to