The floating eye's passive gaze attack causes paralysis with a 2⁄3 chance every time that you attack it in melee (unless that attack kills it). If the floating eye has been cancelled, is blind, or if you cannot see the floating eye, it cannot use its gaze attack. If you have reflection or free action, the paralysis will not affect you. The DevTeam does not consider the lack of any warnings about hitting a floating eye to be a bug, and the encyclopedia entry does warn even unspoiled players of the danger.
If you are paralyzed, the length of time depends on your wisdom and the floating eye's level (typically 2 or 3). If your wisdom is 12 or lower, there is a 25% chance of being paralyzed for exactly 127 turns; otherwise you are paralyzed for (lvl + 1)d70 turns.
Nonetheless, ranged weapons, polearms, or spells will suffice to handle a floating eye; in lieu of a powerful ranged attack, you can also throw junk weapons or rocks. If you are in a room with the floating eye (rather than a corridor) and no other monsters are around, you can keep throwing your melee weapon at it and waiting for it to move so that you can retrieve your weapon.
If wasting turns is not an issue, you can place yourself between the floating eye and an obstacle of some sort (such as a locked door, boulder, or passive creature) so the paralysis will cause no lasting damage other than wasting turns; however, you will then have to contend with hunger instead.
Blinding yourself, e.g. with a blindfold or cream pie will render the floating eye easy to kill, and is preferable if you do not want to take the low chance of a Luck penalty by blinding the eye instead and then killing it. Another option is to make it invisible, usually by zapping it with a wand of make invisible. Cancelling the floating eye also renders it completely harmless.
You can apply a mirror to paralyze a floating eye, but this is not particularly useful as it will still be able to paralyze you.
In dNetHack, the duration of the paralysis effect is shortened to 2d6 turns, making them less dangerous to melee. However, it is still safest to attack them from range, as 12 turns is still enough time for (other) monsters to appear and kill a character.
In FIQHack, floating eyes have an area of effect slowing attack. Hitting one in melee will not paralyze you, but will cause you to accumulate an even longer duration of being slow which will typically last past leaving its slowing area of effect (or killing the floating eye).
In NetHack 4, it is impossible to attack a floating eye in melee without being protected from its gaze in some way. Monsters can still attack floating eyes normally and suffer paralysis. This was implemented to prevent aggravating deaths from early-game movement mistakes, as an accidental button press would often mean instant death.
UnNetHack and xNetHack
Eating a floating eye in Slash'EM Extended is not guaranteed to give telepathy. The paralysis effect from attacking them also has a much shorter time in this variant, making it much less dangerous to melee them.
Floating eyes, not surprisingly, are large, floating eyeballs
which drift about the dungeon. Though not dangerous in and
of themselves, their power to paralyse those who gaze at
their large eye in combat is widely feared. Many are the
tales of those who struck a floating eye, were paralysed by
its mystic powers, and then nibbled to death by some other
creature that lurked around nearby.