in reply to guidance with a realtime log reader

Since Perl integrates well with the shell, you can also transition stepwise into a full Perl implementation.

For example, start with a command-line script:

>tail -f /var/log/ldap.log | perl -ne 'if ( /connection_input: conn=11/ ) { system ( "send an email" ); system ( "restart ldap" ); }'

Then move the code into a Perl script file:

>tail -f /var/log/ldap.log | process.pl

Then take over the function of tail in Perl:

>process.pl

And finally maybe replace some of the system calls with Perl equivalents (eg, Mail::Sendmail)...