A perl question

Bob Bell bbell at hp.com
Tue Apr 20 11:55:00 EDT 2004


On Tue, Apr 20, 2004 at 11:47:06AM -0400, brian <lists at karas.net> wrote:
> On Tue, 2004-04-20 at 11:30, Bob Bell wrote:
> > Can you share code?  I don't see why you'd have a problem.
> > 
> > $ perl -pe '$tag="MyTag";s/::tag/$tag/g;' <<< "foo ::tag ::other"
> > foo MyTag ::other
> 
> Sure... I think I didn't make the request totally clear anyway...
> 
>    $template_message =~ s/::(\w+)/\$$1/g;
>    ## the above line is sort of what I am trying to accomplish.  replace
> all double-colon words with the value of their equivalent variable

Ah, got you now (I think so, at least -- I actually didn't ready very
closely).

$ perl -pe '$tag="MyTag";$other="MyOtherTag";s/::(\w+)/${$1}/ge;' <<< "foo ::tag ::other"
foo MyTag MyOtherTag

Key bit there is "/e".

-- 
Bob Bell



More information about the gnhlug-discuss mailing list