in reply to Detect standby/hibernation mode

The existing hibernate/standby system has hooks for programs to be executed after returning from sleep, usually to be found in /etc/acpi/events/.

Check the documentation of hibernate and acpi, it's much easier than trying to monitor such things from within perl.