Switching to perl to avoid extra pipes