Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8743567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:08+00:00 2026-06-13T11:42:08+00:00

I wrote a little script that connectts to an URL, posts some xml data

  • 0

I wrote a little script that connectts to an URL, posts some xml data and waits for response, so far so good, I need to set timeout but I think I do it wrong because I get this error message:

Can’t locate object method “timeout” via package “HTTP::Headers” at
/usr/share/perl5/HTTP/Message.pm line 644.

this is my little code:

#!/usr/bin/perl
use strict;
use warnings;

use LWP::UserAgent;

my $msg =<< "EOT";
<?xml version="1.0" encoding="utf-8"?>
EOT

my $uri = "http://www.myhostexample.com/script";
my $request = HTTP::Request->new(POST => $uri);
$request->content_type("text/xml");
$request->content($msg);

my $response = LWP::UserAgent->new->request($request);
$response->timeout(10);
#print $response->content . "\n"; # debug

if ($response->content =~ /<?xml/s) {

    print "OK!\n";
}
else {

    print "BAD!\n";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:42:09+00:00Added an answer on June 13, 2026 at 11:42 am

    You need to set timeout for LWP::UserAgent.

    ...
    my $ua = LWP::UserAgent->new();
    $ua->timeout(10);
    
    my $response = $ua->request($request);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a little script which would prompt me for an input, save that
I wrote a little script that check something, and i want a command to
So I wrote a little script in python that brings up a gui with
I was working on a little script that would do some logging for me
I've recently wrote a little script that get's my Twitter feed and caches it
I've recently started learning Python and wrote a little script that informs me when
I wrote this little BASH script that creates a folder,unzips Wordpress and creates a
I wrote a little script that exports certain Excel cell values into Word. However,
I wrote a nice little script to do some lightweight work. I set it
I wrote a little chat plugin that i'll need to use on my site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.