A perl question

2004-04-20 Thread brian
Maybe someone can help? Okay, so I'm trying to do something in perl, a sort of mail merge kind of concept. I have a block of text, something like: Blah blah blah blah ::company foo foo foo foo ::address I also have a bunch of variables populated with data ($company, $address, $city, $state,

Re: A perl question

2004-04-20 Thread brian
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... (BTW, this is part of a trouble ticketing

Re: A perl question

2004-04-20 Thread Bob Bell
On Tue, Apr 20, 2004 at 11:47:06AM -0400, brian [EMAIL PROTECTED] 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

Re: A perl question

2004-04-20 Thread jim . mcginness
Brian wrote: Every s/ operation I come up with always ends up replacing ::tag with the literal $tag. Perl's DWIM features usually pick up a single variable in the replacement part and do the right thing, but you can add a 'e' modifier to the end of the substitution to cause perl to

Re: A perl question

2004-04-20 Thread brian
On Tue, 2004-04-20 at 11:54, Bob Bell wrote: $ perl -pe '$tag=MyTag;$other=MyOtherTag;s/::(\w+)/${$1}/ge;' foo ::tag ::other foo MyTag MyOtherTag Key bit there is /e. Worked perfect! Thanks Bob, and Jim, for the help. -- brian [EMAIL PROTECTED]