According to the LWP::UserAgent documentation, you can set additional headers by passing them as arguments to post
:
my $ua = LWP::UserAgent->new;
my $response = $ua->post($url,
'Content-type' => 'application/atom+xml',
'Authorization' => "MyLogin auth=$token"
);
Note that $ua->post
actually sends the request, so trying to set the headers after calling it, as you do in your example code, is useless. (Not to mention the fact that there is no header
function in the main
namespace unless you import it from somewhere or write it yourself.)