2

I have this function

array_diff(\@DNs, \@prev_DNs);

which must take array references as arguments.

The problem is that I get prev_DNs as an object from

my $prev_DNs = YAML::Syck::LoadFile('temp-previous_DNs.yaml');
print Dumper $prev_DNs;

which outputs

$VAR1 = [
          'abcdef'
        ];

I have tried with

array_diff(\@DNs, \$prev_DNs);

but that didn't work.

Any suggests on how to pass $prev_DNs an an array reference?

2 Answers 2

10

It already is an array reference, actually. So you were actually passsing a reference to the reference by prefixing it with another \. You simply need to pass it as $prev_DNs and it should work.

Sign up to request clarification or add additional context in comments.

Comments

5

According to your Data::Dumper output, $prev_DNs is an array reference, so just use

array_diff(\@DNs, $prev_DNs);

Using

array_diff(\@DNs, \$prev_DNs);

passes a reference to the reference.

Comments

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.