The Grant Panjandrum first appears in Samuel Foote's writings, and is one of the earliest pieces of deliberate nonsense:
So she went into the garden to cut a cabbage leaf, to make an apple pie; and at the same time a great she-bear coming up the street, pops its head into the shop. 'What! no soap?' So he died, and she very imprudently married the barber; and there were present the Picninnies, and the Joblillies, and the Garyulies, and the grand Panjandrum himself, with the little round button at top; and they all fell to playing the game of catch as catch can, till the gunpowder ran out at the heels of their boots.
But it was in 1885 that Randolph Caldecott reworked it into a poem:
So she went into the garden
to cut a cabbage-leaf
to make an apple-pie;
and at the same time
a great she-bear, coming down the street,
pops its head into the shop.
What! no soap?
So he died,
and she very imprudently married the Barber:
and there were present
the Picninnies,
and the Joblillies,
and the Garyulies,
and the great Panjandrum himself,
with the little round button at top;
and they all fell to playing the game of
catch-as-catch-can,
till the gunpowder ran out at the heels of their boots