![]() |
![]() |
![]() |
@foo = ( "apple", "bat", "cat"
);
$foo[0] = "ape";
$foo[3] = "dog";
$foo[1,3] = ( "bear", "dear"
);
@foo = ( @foo, "elk" ); #
Append
@foo = ( "ace", @foo ); # Prepend
- A neater way of adding elements is to use the statement
push(@food, "eggs");which pushes eggs onto the end of the array @food.
- To push two or more items onto the array use one of the following forms:
push(@food, "eggs", "lard"); push(@food, ("eggs", "lard")); push(@food, @morefood);