[Koha-bugs] [Bug 23084] Replace grep {^$var$} with grep {$var eq $_}
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Jun 24 17:45:18 CEST 2019
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23084
--- Comment #7 from M. Tompsett <mtompset at hotmail.com> ---
> This is the whole point of the patch. Have a look at the related bugs, and
> what this patch is trying to prevent. If the variable contains a regex
> character (like parenthesis in the case of bug 22941, or $ in the case of
> bug 23006), then you need to surround your var with \Q\E, see man perlre).
>
> So the patch could have replaced
> grep {/^$var$/} @array
> with
> grep {/^\Q$var\E$/} @array
>
> But I preferred the other solution, I am sure you understand why :)
Yes, anything that requires an escaped solution adds a level of complexity and
poor readability which makes it prone to breaking.
> > Everything else is a result of me seeing tcohen wanting to improve
> > readability of code. "unless grep" is better read as "if none".
>
> I am not tcohen :)
> The patch is a bugfix (updating the status). I would like to prevent other
> issues like the ones listed in see also. Replacing them with none, any or
> anything else will need more grey matter to make sure the changes will not
> introduce a regression. I am not against what you suggest but I think it
> should be done separately.
I agree with that, which is why I just wanted an explanation of the \Q \E
thing. Thanks for that.
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
More information about the Koha-bugs
mailing list