perl: Convert metadata access into a method.