2
use warnings;
use strict;

testfunc();
sub testfunc {
    my @first_pin_name_list=qw(
        VDD2_DDR2_S2_4
        VDD1_DDR2_S2_2
    );

    my @second_pin_name_list=qw(
        VDD2_DDR2_S2_4
        VDD1_DDR2_S2_2
    );
    my @expected_list =qw(
        VDD1_DDR0_S2_[2:1]
        VDD2_DDR0_S2_[5:1]
    );

    my @listoftests = ( 
        {INPUT_LIST => \@first_pin_name_list,OUTPUT_LIST => \@expected_list,OK_2_FAIL=> 0}, 
        {INPUT_LIST => \@second_pin_name_list,OUTPUT_LIST => \@expected_list,OK_2_FAIL => 1}

    );  

    print @expected_list;

    # should show an array but instead debugger shows an array of an array
    my @listtotest = $listoftests[0] -> {INPUT_LIST};
    print "hello";
    return @listoftests;
}

The debugger shows @listtotest containing an array of an array, but I want to see just an array with elements. How can I change my code to show just an array of elements?

1
  • 1
    I'm guessing the debugger is showing you \@listtotest, so that's the top level reference. Others, it would treat each element separately. Commented Jun 10, 2020 at 4:11

1 Answer 1

6

You aren't showing us what the debugger is showing you, but there is no array of arrays.

$listoftests[0]->{INPUT_LIST} is a reference to an array, @first_pin_name_list. If you want to assign the elements in that array to @listtotest, you need to dereference it:

my @listtotest = $listoftests[0]->{INPUT_LIST}->@*;

or on older perls:

my @listtotest = @{ $listoftests[0]->{INPUT_LIST} };
Sign up to request clarification or add additional context in comments.

4 Comments

apologies how can I add pictures on SO? Id like to know for future reference. Ill try this out. this may solve my problems.
can't you copy and paste from the debugger? though I've seen pictures, I have no idea how and find pictures not very useful
ah ok. I can copy from the debugger, just thought it would not look clean on here.
Here is help on making things look clean here stackoverflow.com/editing-help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.