網路管理語言 Perl 入門與實作: | ||
---|---|---|
<<< Previous | 4. Perl 的資料型態 | Next >>> |
由陣列尾端,置入一個元素:
#! /usr/bin/perl @total=(2, 4, 6, 1, 3, 5, "a", "b", "c"); $f2="d"; push @total, $f2; print @total; # 此時 @total 應為 (2, 4, 6, 1, 3, 5, "a", "b", "c", "d"); |
也可以置入另一個陣列:
#! /usr/bin/perl @total=(2, 4, 6, 1, 3, 5, "a", "b", "c"); @t2=qw( John Marry Kenny ); push @total, @t2; print @total; # 此時 @total 應為 (2, 4, 6, 1, 3, 5, "a", "b", "c", "John", "Marry", "Kenny"); |
<<< Previous | Home | Next >>> |
4.2.5 pop | Up | 4.2.7 shift |