-----------------------------------------------------------
@members = ("John","Paul","George","Ringo");
-----------------------------------------------------------


@members

$members[0] $members[1] $members[2] $members[3]
John Paul George Ringo


●[編集]

1.pop(末尾の要素を取り除く)

pop @members

$members[0] $members[1] $members[2] $members[3]
John Paul George


2.push(末尾に要素を追加する)

push (@members,"Yoko")

$members[0] $members[1] $members[2] $members[3] $members[4]
John Paul George Ringo Yoko



3.reverse(逆順に並び替える)

@members = reverse @members

$members[0] $members[1] $members[2] $members[3]
Ringo George Paul John


4.shift(先頭の要素を取り除く)

shift @members

$members[0] $members[1] $members[2] $members[3]
Paul George Ringo


5.unshift(先頭に要素を追加する)

unshift (@members,"Yoko")

$members[0] $members[1] $members[2] $members[3] $members[4]
Yoko John Paul George Ringo



6.sort(リストを ☆ 順にする)

@members = sort @members

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z順

$members[0] $members[1] $members[2] $members[3]
George John Paul Ringo


7.splice(任意の位置に要素を削除/追加する)

splice (@members,1,2)

[1]の要素から2個だけ削除

$members[0] $members[1] $members[2] $members[3]
John Ringo



splice (@members,1,0,"Yoko")

[1]の要素から0削除でその位置に追加

$members[0] $members[1] $members[2] $members[3] $members[4]
John Yoko Paul George Ringo