Lesson 30 of 55
10 mins readPython Nested Data Structures & Arrow Syntax
In Plain English
Perl represents nested data structures using references: anonymous arrays `[...]` and anonymous hashes `{...}` accessed via arrow notation `$struct->{key}->[0]`.
Deep Dive: How It Works
Anonymous Array ([...]): Creates an unblessed array reference.
Anonymous Hash ({...}): Creates an unblessed hash reference.
Arrow Operator (->): Dereferences child nodes: `$users[0]->{name}` or `$users[0]{name}` (arrow is optional between brackets/braces).
Core Rules to Remember

Arrow Dereferencing: Use `->` to navigate nested references: `$db->{users}->[0]->{email}`.

JSON-Ready: Mirrors nested JSON objects and arrays perfectly.
Live Interactive Example
Hit Run Code to see it liveNavigating Array of Hashes
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Output Console
Click "Run Code" to view the rendered output.
How it works: $employees[0]->{name} navigated the array and hash reference cleanly.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Query Nested Cluster Node
Declare a hash reference `my $cluster = { name => "Prod-1", nodes => ["k8s-01", "k8s-02"] };`
Print `"Cluster $cluster->{name}, Leader: $cluster->{nodes}->[0]\n"`.
1
2
3
4
5
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.