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 8488265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:28:58+00:00 2026-06-10T21:28:58+00:00

whilst performing file::fetch on a database of URLs, certain URLs contain only the top

  • 0

whilst performing file::fetch on a database of URLs, certain URLs contain only the top level domain such as http://google.com. How can i construct my if check such that it will verify that there is a file to fetched so when i create a new file::fetch object, it wouldnt throw me this error:

Use of uninitialized value $path in pattern match (m//) at C:/Perl/lib/File/Spec/Unix.pm line 267.
Use of uninitialized value in string eq at C:/Perl/lib/File/Fetch.pm line 395.

Here is a snippet of my code where i am trying to do some verification

my $uri_handle = File::Fetch->new(uri => $url);
my $getfile = $uri_handle ->file;
if ($getfile){
    my $dir_handle = $uri_handle->fetch( to => $dir ) or die "Couldn't fetch file: $uri_handle->error\n";
    #print "[ID:$myid] File fetch completed!\n\n";
}else{
    print "[ID:$myid] There is no file to be fetched from $url\n\n";
}   

But the file method fails too because it could not retrieve a file name at the URL.

Thread 1 terminated abnormally: Can't call method "file" on an undefined value at C:\test\multihashtest2.pl line 102.
  • 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-10T21:29:00+00:00Added an answer on June 10, 2026 at 9:29 pm

    Your perl script will not know what is on the webserver and what isn’t until it tries to load a URI — it doesn’t matter what the URL looks like. You’ll need to attempt to fetch the file and gracefully handle any errors.

    It would help if you posted your code, but you can probably answer your own question by looking at the documentation.

    In particular, the new() method returns false on error, but that’s just validating the URI before it’s actually fetched. When you call fetch() on your File::Fetch object, it Returns the full path to the downloaded file on success, and false on failure.

    So handle what those methods return accordingly.

    EDIT: now that you posted code. If the error is complaining that $uri_handle is undefined, check that $url is being set properly and check for errors. After line 1:

    print $url;
    print $uri_handle->error;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst compiling with avr-gcc I have encountered linker errors such as the following: undefined
Whilst there are many good examples on this forum that contain examples of coupling
I have an issue whilst streaming to a file, I'm sure there is a
Whilst refactoring some old code I realised that a particular header file was full
What is the best way of performing the following in C++. Whilst my current
Whilst working on a SQL Server 2008 database project in Visual Studio 2010 I
Whilst a few questions mention using Lua in conjunction with some other language, I
Whilst reading jQuery Cookbook (Oreilly) last night I came across an each function that
Whilst asynchronous IO (non-blocking descriptors with select/poll/epoll/kqueue etc) is not the most documented thing
Whilst working on some generally horrible Javascript code this morning, I came across the

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.