Logic hook to check if contact exists in contacts module

Hi,

How would I start off a logic hook that takes the data from the ‘contact’ field in the invoices module and checks to see if a record exists in the contacts module?

Then if it does not exist I can create a new record.

pl check this page http://stackoverflow.com/questions/15081906/hook-to-add-value-in-custom-field
you may modify as per requirement and compare the $bean