A Long worm, w~~~~ , is a monster that occupies several squares. Only its head can hurt you, but if you hit it in the middle (even with bare hands), you might merely cut it in half, causing it to divide into two. The tail segment is fair game, and a good way to kill long worms. Unlike the purple worm, the long worm does not engulf its victims.
Neither long worms nor baby long worms can be saddled (and thus, neither can be ridden).
Pet long worms and their baby forms cannot be displaced, which is annoying if you want to improve it with a polytrap. The DevTeam intended the whole length of a long worm to be dangerous, but currently software limitations prevent this.
A long worm technically respects Elbereth, scare monster and similar. However, if a worm is frightened but is currently stuck, it will proceed to attack you with its head and all of its tail segments next to you. This is the only way to see this in action, presumably due to a bug.
The long worm is one of the oldest monsters in NetHack history, having been around since Jay Fenlason's Hack. It is unknown if its behavior was different than it is in modern NetHack.
The long worm represents the sandworm, or rather a small and thus a very young sandworm, from Frank Herbert's Dune series of novels. This is suggested by the fact that long worms are excessively large (for NetHack), by the encyclopedia entry, and by the fact they drop a worm tooth, which may be made into a crysknife, as in the novels. In the Dune series, "specimens [have been] observed over 400 meters" in length.
In the novels, the normal big sandworms can be ridden. As noted above, the NetHack long worm cannot.
The worms of Dune also contribute to the creation of the highly useful and desirable Spice, a fact which is homaged in UnNetHack: if you eat a long worm corpse, the taste is described as "spicy".
[The crysknife] is manufactured in two forms from teeth taken
from dead sandworms. The two forms are "fixed" and "unfixed".
An unfixed knife requires proximity to a human body's
electrical field to prevent disintegration. Fixed knives
are treated for storage. All are about 20 centimeters long.
This page is based on a spoiler by J. Ali Harlow.