Generalized indexing for Perl