naoit0
ブログ
プロジェクト
BBS.pm
BIG-Model
メモ
Search Term
文書の過去の版を開いています
。もしこのまま保存すると、この文書が最新となります。
メディアファイル
{{tag> note:perl unshift shift push pop}} ---json { "title":"配列の操作(push/pop/shift/unshift)", "description":"配列の操作(push/pop/shift/unshift)" } --- \\ ==== <icon name="md:card-text-outline" color="#0000ff" height="32px" width="32px"/> 配列の操作(push/pop/shift/unshift) ==== \\ ^ 関数 ^ 説明 ^ | unshift | 配列の前から追加 | | push | 配列の後ろから追加 | | shift | 配列の前から取り出す | | pop | 配列の後ろから取り出す | \\ <code perl> use Data::Dumper; my @a = (1, 2, 3, 4, 5); print Dumper(@a); # [ 1 2 3 4 5 ] </code> === unshift === <code perl> print "\n"; print " unshift 9"; print "\n"; unshift(@a, 9); # 9 => [ 9 1 2 3 4 5 ] print Dumper(@a); </code> === push === <code perl> print "\n"; print " push 8"; print "\n"; push(@a, 8); # [ 9 1 2 3 4 5 8 ] <= 8 print Dumper(@a); </code> === shift === <code perl> print "\n"; my $shift = shift @a; # 9 <= [ 1 2 3 4 5 8 ] printf " shift=%d\n", $shift; print Dumper(@a); </code> === pop === <code perl> print "\n"; my $pop = pop(@a); # [ 1 2 3 4 5 ] => 8 printf " pop=%d\n", $pop; print Dumper(@a); </code> ~~DISCUSSION~~
人間の証明として、ボックス内の全ての文字を入力してください。
L X M G E
この項目は空のままにして下さい:
保存
プレビュー
キャンセル
編集の概要
User
ログイン
Page
文書の表示
Manage the slots
以前のリビジョン
Backlinks
Metadata Manager
Page Quality
文書の先頭へ
Website
最近の変更
メディアマネージャー
Recent Pages Visited
サイトマップ
Railbar
User
ログイン
Page
文書の表示
Manage the slots
以前のリビジョン
Backlinks
Metadata Manager
Page Quality
文書の先頭へ
Website
最近の変更
メディアマネージャー
Recent Pages Visited
サイトマップ