Oliver Sacks in the NYRB:
Charles Darwin’s last book, published in 1881, was a study of the humble earthworm. His main theme—expressed in the title, The Formation of Vegetable Mould through the Action of Worms—was the immense power of worms, in vast numbers and over millions of years, to till the soil and change the face of the earth. But his opening chapters are devoted more simply to the “habits” of worms.
Worms can distinguish between light and dark, and they generally stay underground, safe from predators, during daylight hours. They have no ears, but if they are deaf to aerial vibration, they are exceedingly sensitive to vibrations conducted through the earth, as might be generated by the footsteps of approaching animals. All of these sensations, Darwin noted, are transmitted to collections of nerve cells (he called them “the cerebral ganglia”) in the worm’s head.
“When a worm is suddenly illuminated,” Darwin wrote, it “dashes like a rabbit into its burrow.” He noted that he was “at first led to look at the action as a reflex one,” but then observed that this behavior could be modified—for instance, when a worm was otherwise engaged, it showed no withdrawal with sudden exposure to light.
For Darwin, the ability to modulate responses indicated “the presence of a mind of some kind.” He also wrote of the “mental qualities” of worms in relation to their plugging up their burrows, noting that “if worms are able to judge…having drawn an object close to the mouths of their burrows, how best to drag it in, they must acquire some notion of its general shape.” This moved him to argue that worms “deserve to be called intelligent, for they then act in nearly the same manner as a man under similar circumstances.”
More here.