AddLastCommentToMail

I would like to use this in the context of a perl script that is run as
an action, is there an example of this available? I don’t want to add
the comment to email but have access to the comments to use in further
processing.