in reply to How to remove everything after last occurrence of a string?

Something about this raises the "X/Y problem" hackles and makes me want to mumble something about using File::Spec and splitdir to break things up into a list of directory components instead (or Path::Tiny and doing . . . something). Or it could just be Monday and I'm making arbitrary connections that aren't there.

That aside the previous quotemeta answer(s) obviously fixes the X issue.

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: How to remove everything after last occurrence of a string?
by Anonymous Monk on Jun 06, 2022 at 20:28 UTC
    Something about this raises the "X/Y problem" hackles and makes me want to mumble something about using File::Spec and splitdir to break things up into a list of directory components instead (or Path::Tiny and doing . . . something).

    definitely x/y, look at the post history