in reply to s// problem
What might be a problem, is that the /i modifier is not working the way you might expect. I think you don't want to mind about the capitalisation of your tags, ie. %TAG%, %tag% and %tAg% should all be equivalent.
If this is the case, you have to store all your templates lowercase (or upper, doesn't make a difference) and then convert the captured string ($1) to this case. The /i modifier has only an influence on how the matching is done, the captured string is always exactly as it was in the original:
'Hello World' =~ /(hello)/i; print $1; # prints 'Hello'
So to solve your problem, you can take advantage of the /e modifier and write something like this:
my %template = ( tag1 => 'test1', tag2 => 'test2', ); while (<DATA>) { print "before: $_"; s/%([^%]+)%/$template{lc($1)}/ge; print "after: $_"; } __DATA__ %tag1% some text %TAG2% some more text
-- Hofmator
|
|---|