[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
Sat Jun 22 03:30:58 CEST 2019


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23084

Jonathan Druart <jonathan.druart at bugs.koha-community.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal

--- Comment #6 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
(In reply to M. Tompsett from comment #5)
> I only thing that really stood out was the C4/Search.pm
> "Why is the \Q and \E missing?"?
> 
> Explain that, I may sign this off.

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 :)

> 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.

-- 
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