Learn to record
Copy Code code as follows:
#!/usr/bin/perl-w
Use strict;
The values of print ' @a @b @c @d are 1 2 3 ', ' \ n ';
My @a = (1..3);
Pop (@a);
The value of print "\@a is the @a,pop to take off the rightmost value of the array \ n";
My @b = (1..3);
Push (@b, ' 4 ');
The value of print "\@b" adds a value to @b,push to the far right of the array. \ n ";
My @c = (1..3);
Shift@c;
The value of print "\@c" is @c,shift to remove the leftmost value of the array. \ n ";
My @d = (1..3);
Unshift (@d,0);
The value of print "\@d" adds a value to @d,unshift to the leftmost of the array. \ n ";
[Root@otrs perl]# Perl pop_push_shift_unshift.pl
The value of @a @b @c @d is 1 2 3.
The value of @a is 1 2,pop the rightmost value of the array is removed
The @b value is 1 2 3 4,push Add a value to the rightmost of the array.
The value of @c is 2 3,shift the leftmost value of the array is removed.
The @d value is 0 1 2 3,unshift Add a value to the leftmost of the array.