0

I have an array reference $data from which I have extract the values.Currently, when I do a Dumper on $data it is as below:

print Dumper @$data;

The output is:

$VAR1 = ' ANC';

$VAR2 = 'BET';

How can I access the elements in $Var2?

5
  • 2
    I got it.. it's by $data->[1] Commented Apr 24, 2014 at 23:22
  • If you have found your own solution then please write an answer and accept it. That way other users of the site will see that the problem has been resolved, and people who have a similar issue can come here to find an answer Commented Apr 24, 2014 at 23:47
  • @Miller: The OP's solution belongs as an answer, not as an update to his question :) Commented Apr 24, 2014 at 23:49
  • @Borodin I was just trying to make sure that people saw that he found an answer and didn't waste time. I agree that the ideal intended place is the answer section though Commented Apr 25, 2014 at 0:07
  • @Miller: In retrospect I agree. I didn't expect him to just run away with his answer without giving anything back, but hey Commented Apr 25, 2014 at 1:01

1 Answer 1

1

Also, you can use $$data[1], since $data is a reference to an array, you can use it just like an ordinary array, $data is the name, so you can use @$data represent the whole array, and $$data[n] to access element in array.

There is more than one way to do it!

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

3 Comments

I realize you don't have the privilege of commenting on other people's questions yet, but a comment is the best place if you have to make a joke.
@sloger: Your answer is valid, but you should explain yourself as well as writing bare code. I tried to edit your answer to remove the graphic but that left it too short. If you can write something useful to explain why your answer is a good one then please do so, otherwise I will vote for it to be deleted
@sloger: Please stop using character art in your posts

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.