in reply to Re: Store regex modifiers in variables?
in thread Store regex modifiers in variables?

I was looking for a similar issue. My problem wasn't with a match, but a substitution. This node is fairly old, however very relevant to my problem and I'm adding my comments in case someone needs a similar answer.

<bold>Project details:</bold>
I'm building a "interactive shell" to make our life easier. (DBA Group) In one shell I plan to tie Oracle, Sybase (DBI) and Sybase Replication together. Replication is also managed via DBI, but I provide a customized syntax for manipulating it. (They don't provide bulk loading functionality for heterogeneous environments. Thats done via other Perl scripts/modules) ;) I wanted to provide the user with a way of manipulating the input "buffer" via regex.

The only modifiers I allow are i,s,m & g for simplicity. ('e' & 'm' would be more difficult to "grammerize" than I'm willing to spend time on) While i,s & m are fine using the syntax (?$mods), I don't believe the g is. Well, no big deal.. My solution:

if ($mods=~s/g//g) { $buffer=~s/(?$mods)$expr1/$expr2/g; } else { $buffer=~s/(?$mods)$expr1/$expr2/; }

Hope this helps someone else, like myself! Great thread, thanks to all!

Regards,
SMF 8)