[PATCH manager 0/1] ceph: tools: fix local monitor detection in purge_all_ceph_files

Kefu Chai
2026-03-31T01:27:30Z

While reading the code, the call 'grep($addr, @$monlist)' caught my
eye -- 'grep' made me think of grep(1), which takes a regular
expression as its first argument. But the first argument here is
clearly not a regex.

That led me to https://perldoc.perl.org/functions/grep, where I read
that grep(EXPR, LIST) evaluates EXPR for each element with $_ aliased
to the current element -- similar to a lambda that takes $_ as its
implicit parameter. The expression in our case, '$type->{$name}->{addr}',
does not reference $_ at all, making it a constant predicate. It
evaluates to the same value (the addr string) for every element in the
list, so the result is the full list length rather than a membership
test.

I then searched for a Perl operator like 'in' or 'contains' to express
membership directly, but found no such built-in. List::Util::any is the
closest equivalent -- it makes the per-element comparison explicit and
short-circuits on the first match.

Kefu Chai (1):
ceph: tools: fix local monitor detection in purge_all_ceph_files

PVE/Ceph/Tools.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

--
2.47.3