From: Kefu Chai <k.chai@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager 0/1] ceph: tools: fix local monitor detection in purge_all_ceph_files
Date: Tue, 31 Mar 2026 09:27:45 +0800 [thread overview]
Message-ID: <20260331012746.763863-1-k.chai@proxmox.com> (raw)
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
next reply other threads:[~2026-03-31 1:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 1:27 Kefu Chai [this message]
2026-03-31 1:27 ` [PATCH manager 1/1] " Kefu Chai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260331012746.763863-1-k.chai@proxmox.com \
--to=k.chai@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox