sub index_of { my $thing = shift; my @indexes = grep $_[$_] eq $thing, 0..$#_; wantarray ? @indexes : $indexes[0]; }