This is a nonsensical poem composed by Samwise Gamgee and it is also found in The Lord of the Rings. Earlier versions by Tolkien called the poem Pero & Podex or Root of the Boot and had been written/published between 1920-1936.
This poem is written by Samwise Gamgee and he has possibly based some of the characters on real hobbits. It features a lonely Troll befriending Perry-the-Winkle, a young hobbit. In ~1928 Tolkien wrote an earlier version to this poem called The Bumpus for a series of works.