The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Mac::SleepEvent - run Perl code on Mac OS X sleep and wake events


  use Mac::SleepEvent;
  my $sn = Mac::SleepEvent->new(
   wake   => sub {print "Waking up...\n"},
   sleep  => sub {print "Going to sleep\n"},
   logout => sub {exit(0)},


Mac::SleepEvent provides callbacks to run code when Mac OS X goes to sleep, wakes up, or logs out (same as shutdown). When the listen method is called, the program will enter a run loop, awaiting events from the OS.


Mac::SleepEvent requires the Foundation module, which is only included with the OS X system perl.



This will start the run loop.


Lee Aylward <>


Copyright 2009 Lee Aylward.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 38:

'=item' outside of any '=over'

Around line 42:

You forgot a '=back' before '=head1'