in reply to Re^3: reg. expr. multiple substitutions
in thread reg. expr. multiple substitutions

That would probably work, but I'm never quite sure that there is any benefit to pre-compiling a regex with qr// if you are going to then interpolate that into the m// or s/// construct to use it.

Especially when the use as a hash key converts it back to a plain string anyway.

But, what am I missing about the benefit over quotemeta? Iff you want to have a replacement like 'a[0]' => 'a[1]', you either have to run it through quotemeta or escape it by hand if you want to use qr//, don't you?

Replies are listed 'Best First'.
Re^5: reg. expr. multiple substitutions
by BrowserUk (Patriarch) on May 17, 2012 at 15:41 UTC
    Iff you want to have a replacement like 'a[0]' => 'a[1]', you either have to run it through quotemeta or escape it by hand if you want to use qr//, don't you?

    Exactly my point. I do not see the benefit of qr// for this purpose.

    But in the end, without the OP posting some realistic examples, this discussion is pretty much pointless.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?