"Perl Language Getting Started" self-study notes - Chapter 3 1 Mainly some arrays and list introductions and techniques, which can fully feel the convenience and power of Perl :) Array: 1. Array is from 0 to start counting. 2. Receive the last element: $ # Rocks 3. Simple value: Rocks [-1] interval operator to indicate the direct amount of direct: (1..5): Represents 1, 2, 3, 4, 5 (1.7..5.7): Represents 1, 2, 3, 4, 5 decimal removed (5..1): empty list, only count Qw shortcuts online to represent the list direct: QW / Fred Barney Betty Wilma Dino /; QW {/ usr / local / words /Home/rootbeer/.ispell_english} can be easily defined by Qw operators, and the front and back operators can be defined by themselves. List assignments: ($ FRED, $ BARNEY, $ DINO) = ("Flintstone", "Rubble", undef; variable transformation method: ($ FRED, $ barney) = ($ BARNEY, $ FRED); array assignment: @ Rocks = Qw / BEDROCK SLATE LAVA /; Array Copy: @ Rocks = @ Copy Pop and Push Operator: Pop Function Removes the last element of an array and returns it: @ array = 5..9; $ fred = POP @Array); # $ fred Get 9, @ Array now has (5, 6, 7, 8) $ fred = pop @Array; # $ fred get 8, parentheses is not the same, @ array now (5, 6, 7 Push function Add an element Push (@Array, (5, 7, 0) Push @ array, 8; # @Array (5, 6, 7, " 0, 8) Push @ array, 1..10; # @Array adds 10 new elements Shift and unshift functions: Operating the beginning of the array, similar to pop and push; @ array = QW # Dino Fred Barney # $ a = shift (@Array); # $ a get Dino, @ array now has ("fred", "barney"); unshift @ array, 4; # @Array now has 4, Fred, Barney