Anyone here know how to capture events?

iTunes will send the following according to the SDK:
Code:
HRESULT _IiTunesEvents::OnPlayerPlayEvent  (  [in] VARIANT  iTrack   )   
HRESULT _IiTunesEvents::OnPlayerPlayingTrackChangedEvent  (  [in] VARIANT  iTrack   )   
HRESULT _IiTunesEvents::OnPlayerStopEvent  (  [in] VARIANT  iTrack   )
I want to capture those events in a perl script to run actions but can't seem to figure out how to get those events.

thanks in advance!