I have a piece of python code, that I need to convert it to perl, but unfortunately I am not good in perl, so sorry if the question is simple. I would like to check STDOUT and STDERR for a specific word. Here is the python code:
p = subprocess.Popen("bmod -b " + beginTime + " " + job_id + "; exit 1;",
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
while p.poll() is None:
err = p.stderr.readline().decode('utf_8')
out = p.stdout.readline().decode('utf_8')
if "changed" in err or "changed" in out:
subprocess.Popen("echo rescheduling was successful!", shell=True)
os._exit(0)
I read some documentations and open3 function may work here, but for p.poll() part I am not sure what to use.