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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:57:22+00:00 2026-06-15T10:57:22+00:00

Im using LWP to download an executable file type and with the response in

  • 0

Im using LWP to download an executable file type and with the response in memory, i am able to hash the file. However how can i save this file on my system? I think i’m on the wrong track with what i’m trying below. The download is successful as i am able to generate the hash correctly (I’ve double checked it by downloading the actual file and comparing the hashes).

use strict;
use warnings;
use LWP::Useragent;
use Digest::MD5    qw( md5_hex );
use Digest::MD5::File qw( file_md5_hex );
use File::Fetch;

my $url = 'http://www.karenware.com/progs/pthasher-setup.exe';
my $filename = $url;
$filename =~ m/.*\/(.*)$/;
$filename = $1;
my $dir ='/download/two';
print "$filename\n";

my $ua = LWP::UserAgent->new();
my $response = $ua->get($url);
die $response->status_line if !$response->is_success;
my $file = $response->decoded_content( charset => 'none' );
my $md5_hex = md5_hex($file);
print "$md5_hex\n";
my $save = "Downloaded/$filename";
    unless(open SAVE, '>>'.$save) {
        die "\nCannot create save file '$save'\n";
    }
    print SAVE $file;
    close SAVE;

If you are wondering why do i not instead download everything then parse the folder for each file and hash, its because im downloading all these files in a loop. And during each loop, i upload the relevant source URL (where this file was found) , along with the file name and hash into a database at one go.

  • 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-15T10:57:23+00:00Added an answer on June 15, 2026 at 10:57 am

    Try getstore() from LWP::Simple

    use strict;
    use warnings;
    use LWP::Simple qw(getstore);
    use LWP::UserAgent;
    use Digest::MD5    qw( md5_hex );
    use Digest::MD5::File qw( file_md5_hex );
    use File::Fetch;
    
    my $url = 'http://www.karenware.com/progs/pthasher-setup.exe';
    my $filename = $url;
    $filename =~ m/.*\/(.*)$/;
    $filename = $1;
    my $dir ='/download/two';
    print "$filename\n";
    
    my $ua = LWP::UserAgent->new();
    my $response = $ua->get($url);
    die $response->status_line if !$response->is_success;
    my $file = $response->decoded_content( charset => 'none' );
    my $md5_hex = md5_hex($file);
    print "$md5_hex\n";
    my $save = "Downloaded/$filename";
    getstore($url,$save);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I wrote a quick script to download files using LWP::Simple library and its getstore()
I am trying to download a file from a site using perl. I chose
I get this error while using cookie_jar method: Can't call method cookie_jar on an
Using gdb, I can type 'info threads' or 'thread apply all backtrace' to get
I'm trying to crawl this page using Perl LWP: http://livingsocial.com/cities/86/deals/138811-hour-long-photo-session-cd-and-more I had code that
I am using LWP to download content from web pages, and I would like
Using the following code: use LWP::Simple; my $url= http://example.com; my $html= get $url; I
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using CI for the first time and i'm smashing my head with this seemingly

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.