John,
Somehow I over looked your answer to my question and have since
posted a couple more similar questions.  Your answer here pretty much
provides a way to make my scripts work.... Thanks.

If possible, please note my comments in the code below and point me to
something that will allow me to understand what is happening in that
syntax.

"John W. Krahn" <[EMAIL PROTECTED]> writes:

> Harry Putnam wrote:
>> 
>> Something I'm messing with today and can't get right.  I've presented
>> a simplified version of what I'd like to do.  It amounts to setting
>> the strings inside a s/some_re/some_rep/ type action.
>> 
>> I can get it to work fine if both elements are simple and don't
>> involve grouping and back reference.  But grouping and back reference
>> would make my script (the real one ) considerably more versatile.
>> 
>> Examples:
>> 
>> cat rein.pl
>> 
>>   #!/usr/local/bin/perl -w
>>   $strp_re  = shift;
>
> You COULD compile this to a regex now which is a bit more efficient.
>
>     my $strp_re  = qr/@{[shift]}/;

I find `qr' explained very briefly in `Programming Perl [3rd]' but
not enough to understand what role these play => [EMAIL PROTECTED]'

I understand what shift is doing but not the rest.

>>   $rein_str = shift;
>> 
>>   while(<>){
>>      chomp;
>>      $pre_out = $_;
>>      ($out = $pre_out) =~ s/$strp_re/$rein_str/;
>
>        ($out = $pre_out) =~ s/$strp_re/qq["$rein_str"]/ee;

I find no reference to `qq' used like this in `Programming Perl
[3rd]'.  Ditto for a double `ee' in this context.  I can sort of see
what is happing ... That is, $rein_str is being presented to the
interpreter in such a way that it knows how to read it.  But not
clear what all is happening here.

>>      print "$out\n";
>>   }


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to