This is highly importable, however if you're using XFree (maybe other X servers as well), you could execute xset with the led option. For example, xset led 1 turns on the first LED, whereas xset -led 2 turns off the second.
For XFree be sure to have
Xleds 1 2 3
in your XF86Config or equivalent, otherwise
you won't be able to control the LEDs.
The X way of doing it is the XChangeKeyboardControl call, available from X11::Protocol as the ChangeKeyBoardControl method of an X11::Protocol instance.
If you run Linux in console mode you might execute setleds. It is implmented using KDGETLEDS and KDSETLEDS ioctl calls for the current terminal. Since ioctl is available under Perl, you can have a look at the appropriate C headers and look at the source code of setleds to figure out exactly what to do.
Regarding Windows, once I've been given the following snippet of VBScript, me being totally incompetent and in need of a quick hack to turn numlock off on a notebook at
startup:
set wshShell = CreateObject("WScript.shell")
wshShell.sendkeys "{NUMLOCK}"
I'm sure you can adapt it to Perl if needed.
-- TMTOWTDI |