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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:02:01+00:00 2026-06-18T04:02:01+00:00

I have a setter sub setAssignmentStatus which takes an array of hashes ( AoH

  • 0

I have a setter sub setAssignmentStatus which takes an array of hashes (AoH from here on) and another parameter (do not concern yourself with this as that part works), and does something iterating through the AoH to set another entry in each hash element. It does not return anything because I want to use the same AoH object with the added entries after it is pulled through the setter sub and not construct a whole new AoH and repopulate the entries. Here is the setter:

sub setAssignmentStatus
{
    my $fileFlatArySclr = $_[0];
    my $cfgFile = $_[1];

    #here I convert the AoH from the scalar necessary for the sub to its native form
    my @fileFlatAry = @$fileFlatArySclr;

    #this works, don't worry
    my %cfgVarHash = getConfigVars($cfgFile);

    foreach my $fileVarHashSclr(@fileFlatAry)
    {
        #convert each AoH entry from scalar necessary for iteration to native hash
        my %varHash = %$fileVarHashSclr;

        my $varName = $varHash{'VAR_NAME'};

        my $asgnLineCnt = $varHash{'ASGN_CNT'};

        my $asgnSts;
        my $fileAsgnSts; 
        my $cfgAsgnSts; 

        if($asgnLineCnt > 0) { $fileAsgnSts = 1; } else { $fileAsgnSts = 0; }

        my $cfgAsgnLine = $cfgVarHash{$varName};

        if($cfgAsgnLine ne undef) { $cfgAsgnSts = 1; } else { $cfgAsgnSts = 0; }

        $asgnSts = $fileAsgnSts.$cfgAsgnSts;

        #debug to make sure $asgnSts is not null in the first place (it is not!)
        print "\n*** setting ASGN_STUS of ".$varName." to ".$asgnSts;

        #Here we set ASGN_STUS for every iteration
        $varHash{'ASGN_STUS'} = $asgnSts;
    }
}

It is called as follows:

setAssignmentStatus(\@fileFlatAry, $cfgFile);

However, after sending the @fileFlatAry AoH through setAssignmentStatus, each element hash does not contain an ASGN_STUS entry. Why is that and how can I fix it?

My suspicion is that I am doing something wrong with the \ modifier, which is how I am getting the data structure to be passed as a scalar parameter to the sub but I am not sure.

  • 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-18T04:02:03+00:00Added an answer on June 18, 2026 at 4:02 am

    You modify %varHash instead of modyfing the referenced hash. Stop copying everything into local variables and modyfying the local variables.

    $varHash{'ASGN_STUS'} = ...;
    

    should be

    $fileVarHashSclr->{'ASGN_STUS'} = ...;
    

    I wouldn’t do my @fileFlatAry = @$fileFlatArySclr; either. Pure waste.

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

Sidebar

Related Questions

I have a string array selectCancel with setter and getter methods, which is a
I have a list of items ('sections') which has a getter and a setter.
Is there a way in C# to have a setter inherit from something that
I have a JSF component which is initialized from a managed bean's getter getProperty()
I have textfield array which has to accept only numeric values i.e. 1-5. <s:textfield
I have a setter like this: - (UIImagePickerController *) foto { if (_foto ==
I'm using Java. I want to have a setter method of one class that
i have a class: class MyClass { @Getter @Setter int a; @Getter @Setter int
I have two domain classes (getter setter of two tables): Contact Information and Address
I have a Class that has a private variable with a public setter/getter function:

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.