in reply to complex data structures

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1172399 use strict; use warnings; my @AnData = 'A'..'Z'; my %AN=(data => \@AnData); print $AN{data}[0x16], ' ', $AN{data}[22];

prints:

W W

Note that 0x16 is the same as 22.

Replies are listed 'Best First'.
Re^2: complex data structures
by perltux (Monk) on Sep 23, 2016 at 03:12 UTC
    Thanks for pointing that out, but that was just a copy and paste mistake, not what my actual question is about.

      I think he meant to demonstrate that you do not need \$ (or $$) to access the data you have described. However, if you want to create a reference to that single piece of data then you do indeed have to use the prefix \ because that's exactly what that prefix does.

      There are also other ways to create references to data, such as {} and []. References are described in perldoc perlref

      If this does not answer your question, maybe you need to provide a little more context to help us understand why this does not solve your problem?

      -- FloydATC

      Time flies when you don't know what you're doing

      I thought your actual question was about a \.

      Please note my print statement does not need the \ to work correctly.

      Perhaps I am misunderstanding your question. Please provide an actual runnable program that shows a failure when the \ is not used, and success when the \ is used, and we can proceed from there.