You are not allowed to "open" to a command that pipes both in and out, but see IPC::Open2, IPC::Open3,...