Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Perl >> Snippet

09 Arrays


pop @myarray                  # remove from top of array
push @myarray , new_list       # add to top of array - return removed item

shift @myarray                # remove from bottom of array - return removed item
unshift @myarray , new_list    # add to bottom of array

pop /shift/unshift/ push act on @_ in a subroutine  ( if not specified)
pop /shift/unshift/ push act on @ARGV outside a subroutine ( if not specified)

splice @myarray , offset                 # remove elements starting from offset
splice @myarray , offset, length         # only remove length elements
splice @myarray , offset, length , list   # replace removed elements with list

@sortedarray = sort @myarray            # sort by ASCII

Range operators:
(1. . 10)            #range operator
(1. . 10, 21. . 30)    #range operator
(a .. z)             #range operator
(aa .. zz)           #range operator