Catman...:index(3pm)
β¨ NAME β¨
okay so bestie, welcome to Catman...:index(3pm) π β this is a page from the User Contributed Perl Documentation crew, and it's giving absolute baddie energy. It's the manual for Catmandu::Fix::index β the fix that goes and finds every single position of a (sub)string inside a field. like a little treasure hunt but for characters. πβ¨
πΈ SYNOPSIS πΈ
so here's the whole vibe, no cap. first up, strings β you're hunting for where a character shows up inside a string:
# On strings, search the occurence of a character in a string
# word => "abcde"
index(word,'c') # word => 2
index(word,'x') # word => -1
okay so 'c' lives at index 2, iconic. and 'x'? not there at all bestie, so you get -1 π (that's the universal "nope, didn't find it" signal, periodt).
now the multiple era β when you want every position and not just the first one:
# word => "abccde"
index(word,'c', multiple:1) # word => [2,3]
look at that, [2,3] β two 'c's, two positions, both of them slaying. π
and then we get into the '*' magic, where you loop over all the word(s):
# word => [a,b,bba] , loop over all word(s) with the '*'
index(word.*,'a') # word -> [0,-1,2]
0, -1, 2 β the -1 is just b being unbothered and having zero as, we respect it. π
last but never least: arrays, where you're searching for the occurrence of a word in an array instead:
# words => ["foo","bar","foo"]
index(words,'bar') # words => 1
index(words,'foo', multiple: 1) # words => [0,2]
'bar' shows up at 1, and both the 'foo's come through at [0,2] β main character energy from the array, honestly. π
π¦ SEE ALSO π¦
Catmandu::Fixβ go read it bestie, it's the whole family tree and you'll need the lore. π
and that's the page, angel! π this masterpiece was living in perl v5.40.1 and it dropped on 2026-01-24 β so if you ever need to cite your sources, you know exactly where it came from. go forth and index everything, iykyk β¨π«Ά
π¦ where this page comes from
- ubuntu resolute: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-perl 1.2025-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms