migrating from perl to curl