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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:29:48+00:00 2026-05-16T11:29:48+00:00

I am basically trying to pass a string and a hash to a subroutine

  • 0

I am basically trying to pass a string and a hash to a subroutine in perl.

sub coru_excel {
    my(%pushed_hash, $filename) = @_;
    print Dumper(%pushed_hash);
}

But it seems data is getting mixed up. The dumped data also includes the $filename. here is the output.

...................
$VAR7 = 'Address';
$VAR8 = [
          '223 VIA DE
................
        ];
$VAR9 = 'data__a.xls'     <----- $filename
$VAR10 = undef;
$VAR11 = 'DBA';
$VAR12 = [
           'J & L iNC
..................
         ];

Here is how I called the subroutine.

coru_excel(%hash, "data_".$first."_".$last.".xls");
  • 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-16T11:29:48+00:00Added an answer on May 16, 2026 at 11:29 am

    Arguments are passed to subroutines as one undifferentiated list.

    One solution is to reverse the order of the arguments so that the scalar is first.

    sub coru_excel {
        my($filename, %pushed_hash) = @_;
    }
    
    coru_excel("FILE_NAME", %hash);
    

    Another approach is to pass the hash by reference:

    sub coru_excel {
        my($pushed_hash_ref, $filename) = @_;
    }
    
    coru_excel(\%hash, "FILE_NAME");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well basically I am trying to pass a string to a uiwebview that just
I'm basically trying to pass a method to another class to be called later,
I'm basically trying to iterate through a dict and print out the key /
I'm basically trying to create a url friendly query string with user input. The
I'm trying to pass a 'string' argument to a view with a url. The
I'm trying to use .html() or .contents() but i have strange behaviours I basically
I'm trying to seperate a number from a string in python. Basically I want
I'm trying I have a string that I pass into my function from user
I'm basically trying to pass a GET value from the construct function to the
Basically what I'm trying to do is take a String, and replace each letter

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.