Introduction to Perl pop push shift unshift instance

Source: Internet
Author: User

Learn to record CopyCodeThe Code is as follows :#! /Usr/bin/perl-W
Use strict;
The value of print '@ A @ B @ C @ D is 1 2 3', "\ n ";
My @ A = (1 .. 3 );
Pop (@ );
Print "\ @ A: The value is @ A. Pop removes the rightmost value of the array \ n ";
My @ B = (1 .. 3 );
Push (@ B, '4 ');
Print "\ @ B's value is @ B, and push adds a value to the rightmost of the array. \ N ";
My @ C = (1 .. 3 );
Shift @ C;
The value of print "\ @ C is @ C, and shift removes the leftmost value of the array. \ N ";
My @ d = (1 .. 3 );
Unshift (@ D, 0 );
The value of print "\ @ D is @ D, and unshift adds a value to the leftmost of the array. \ N ";

[Root @ otrs Perl] # Perl pop_push_shift_unshift.pl
@ A @ B @ C @ D is set to 1 2 3.
@ A: The value is 1 2. Pop removes the rightmost value of the array.
The value of @ B is 1 2 3 4, and push adds a value to the rightmost of the array.
The value of @ C is 2 3, and shift removes the leftmost value of the array.
The value of @ D is 0 1 2 3, and unshift adds a value to the leftmost of the array.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.