Robert's Perl Tutorial

Jiggerypokery with Arrays



unshift (@cities, $last);


sub look {
        print "Names : @names\n";
        print "Cities: @cities\n";

Now we have two arrays. The pop function removes the last element of an array and returns it, which means you can do something like assign the returned value to a variable. The unshift function adds a value to the beginning of the array. Hope you didn't forget that &subroutinename calls a subroutine. Presented below are the functions you can use to work with arrays: