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

  • Home
  • SEARCH
  • 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 7734655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:18:15+00:00 2026-06-01T07:18:15+00:00

Here is my code #!usr/bin/env perl # Setup includes use strict; use XML::RSS; use

  • 0

Here is my code

#!usr/bin/env perl
# Setup includes
use strict;
use XML::RSS;
use LWP::Simple;
# Declare variables for URL to be parsed
my $url2parse;
# Get the command-line argument
my $arg = shift;
# Create new instance of XML::RSS
my $rss = new XML::RSS;
# Get the URL, assign it to url2parse, and then parse the RSS content
$url2parse = get($arg);
die "Could not retrieve $arg" unless $url2parse;
$rss->parse($url2parse);
# Print the channel items
foreach my $item (@{$rss->{'items'}}) {
     next unless defined($item->{'title'}) && defined($item->{'link'});
     print "<li><a href=\"$item->{'link'}\">$item->{'title'}</a><BR>\n";
}

when I typed in %perl myRss.pl http://www.nytimes.com/services/xml/rss/userland/Education.xml,
the console runs a while and returns
“Could not retrieve http://www.engadget.com/rss.xml at myRss.pl line 14.”
Where does my code go wrong?

  • 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-01T07:18:17+00:00Added an answer on June 1, 2026 at 7:18 am

    Well, the output really says it all: at myRss.pl line 14

    die "Could not retrieve $arg" unless $url2parse;
    

    This means LWP::Simple failed to fetch the URL you provided. If you want to know why it fails, you should probably switch to LWP::UserAgent. Something like this shoud tell you more:

    use LWP::UserAgent;
    sub get {
        my $url = shift;
        my $ua = LWP::UserAgent->new();
        my $res = $ua->get($url);
    
        die ("Could not retrieve $url: " . $res->status_line) unless($res->is_success);
        return $res->content;
    }
    

    Simply remove LWP::Simple from your code and you can use your “custom get()” subroutine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my code: #!/usr/bin/env perl sub start { ... } sub stop {
In Groovy code something simple: #!/usr/bin/env groovy public class test { boolean val def
the code here below: #!/usr/bin/env python import wx class MyForm(wx.Frame): def __init__(self): wx.Frame.__init__(self, None,
I'm learning grit (version 2.4.1). Here is my basic code: #!/usr/bin/env ruby -wKU require
Here is the code: 1 #!/usr/bin/env python 2 3 import re, os, sys, jira,
I have the following code: #!/usr/bin/env python import sys from PyQt4 import QtGui, QtCore
The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
enter code here Hi All, I have a simple windows service application that connects
enter code here I have a ListView that have a different Layout XML for
So I'm having some problems adding a wsse header to my SOAP request. #!/usr/bin/perl

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.