Dermatomal supply of the perianal skin is
The Inferior rectal nerves (inferior anal nerves, inferior hemorrhoidal nerve) usually branch from the pudental nerve but occasionally arises directly from the sacral plexus; they cross the ischiorectal fossa along with the inferior hemorrhoidal vessels, toward the anal canal and the lower end of the rectum, and is distributed to the spincher ani externa and to the integument (skin) around the anus. image ref - Netter atlas
S1
L2
L3
S4
Abdomen and pelvis