subscript adverb :p

Documentation for subscript adverb :p, assembled from the following types:

language documentation Subscripts

From Subscripts

(Subscripts) subscript adverb :p

Return both the index/key and the value of the element, in the form of a Pair, and silently skip nonexistent elements:

my  @tens = 0102030;
say @tens[1]:p;        # OUTPUT: «1 => 10␤» 
say @tens[042]:p;  # OUTPUT: «(0 => 0 2 => 20)␤» 
 
my  %month = Jan => 1Feb => 2Mar => 3;
say %month<Feb>:p;          # OUTPUT: «Feb => 2␤» 
say %month<Jan Foo Mar>:p;  # OUTPUT: «(Jan => 1 Mar => 3)␤» 

If you don't want to skip nonexistent elements, use the negated form:

say %month<Jan Foo Mar>:!p;  # OUTPUT: «(Jan => 1 Foo => (Any) Mar => 3)␤» 

Can be combined with the :exists and :delete adverbs.

See also the pairs routine.