in reply to Re^2: Cannot access HTTP::Response content properly
in thread Cannot access HTTP::Response content properly

Your open statement

open(MYFILE, '/tmp/data.txt');
is opening the file for reading only. (See open.) Try this:
open(MYFILE, '>', '/tmp/data.txt') || die("Cannot open /tmp/data.txt: +$!");