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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:15:35+00:00 2026-05-23T10:15:35+00:00

I’m trying to use the IO::Uncompress::Gunzip module. Per it’s documentation, I should be able

  • 0

I’m trying to use the IO::Uncompress::Gunzip module. Per it’s documentation, I should be able to provide an output variable of an array reference to have it push results onto that array (documentation here). When I do the following:

my $blah = [];
gunzip $blah_gz => $blah or die("gunzip failed: $GunzipError\n");

Gunzip just pushes a single scalar containing all the lines of the file onto $blah, essentially treating its first elem as a scalar reference. Am I doing something wrong? Is this a bug? Is it desired behavior? Whatever it is, it’s annoying.

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

    This is doing exactly what it is supposed to be doing. According to the docs, supplying an array reference for the output will uncompress the contents then push it onto the supplied array.

    Perhaps what you thought it should do is put the lines of the uncompressed output into your array? If you want something like that do:

    gunzip $blah_gz => \ $a_scalar_var  or die "blah...\n";
    my @contents = split($/, $a_scalar_var);
    

    Note, the contents will not have the trailing new line, so you don’t need to chomp each line as you process it, but you will have to use say or do something like print $_, "\n" when you go to print it out.

    If you are short on memory, and don’t want to essentially keep three copies of your data around, and $blah_gz and $a_scalar_var aren’t going to drop out of scope (e.g. when you return from the function doing the uncompression), you can add in:

    undef $blah_gs;
    undef $a_scalar_var;
    

    after you have @contents generated.

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

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I'm parsing an XML file, the creators of it stuck in a bunch social
I am using Paperclip to handle profile photo uploads in my app. They upload

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.