To communicate with a sub-process bi-directionally you need at least
IPC::Open2, just
open is not enough (see
Bidirectional Communication with Another Process for more info).
You can also switch from
curl to
HTTP::Tiny which is in core since
2011-01-17 and supports HTTP basic authentication via URIs like
http://user:password@example.org/.