added c and perl versions