The Spanish preterite perfect or
past anterior is used to indicate an action in the past that occurred
just before another action in the past.
The preterite perfect is very rare in spoken Spanish - it is found almost
exclusively in formal writing such as literature. It can only be used after
expressions like apenas,
cuando, después de que, and tan pronto como, that mean "when"
or "as soon as." Its non-literary equivalents are the
preterite and pluperfect.
Cuando hubo salido, empecé a llorar.
When he had left, I began to cry.
Después de que hubimos comido, fuimos a la tienda.