Using Perl to read Linux events

For a simple demo that played a movie on a BeagleBoard, I wanted to add a simple mechanism to start the movie over again if the USER button was pressed.

To read a Linux input event, it is as simple as just performing a read. The only trick to this for me, however, is that I wanted the read to timeout. This was resolved by using the Perl alarm() function can catching the signal within an eval().

I’ve uploaded a gist of my example play_movie.pl script: