Perl has sigils for different data types.
$foo="bar"; #scalar/string
%hash = { "key" => "value", "key2" => "val2" }; #hashmap
@arr = ( 1, 2, "three", 4); #array
But, it also has references, like pointers. $array_ref=\@somearray; # array ref
$hash_ref=\%somehash; # hash ref
$scalar_ref=\$some_scalar; # scalar ref
So, you can put scalars into arrays and hashes, refs into hashes and arrays, etc, etc. At whatever nested depth you want. But you have to extract pieces later. And Perl, as usual, allows a zillion ways to do it. These are all exactly the same thing: $$arrayref[0] = "data";
${$arrayref}[0] = "data";
$arrayref->[0] = "data";
So imagine you need to extract a string that's at the bottom of some data structure. Here's an example: @IP = ('192.168.1.10','192.168.1.15');
@PORT = ("5000","5002");
@TCP = ("Q931","H225","H245");
@LAYER = ("ETHERNET","IP",\@TCP);
@PKT = (
\@IP,
\@PORT,
\@LAYER
);
$array_ref = \@PKT;
I can extract something using different approaches, like: ${${${$array_ref}[2]}[2]}[1];# oof!
# same result, looks better, but imagine
# we put a hash in the data structure, or
# had deeper structures
$array_ref->[2]->[2]->[1];