www.perl.com
Perl Programming
List Operators
  • sort
    • Sorts the list, alphabetically by default
    • Many other sorting methods available
    • perldoc -f sort gives function details
  • reverse
    • In scalar context, concatenates the list and reverses the resulting string
    • In list context, reverses the list

        my @animals = qw(dog cat fish parrot hamster);
        my @sorted = reverse sort @animals;
        print "I have the following pets: @sorted\n";

        my $word = "backwards";
        my $mirror = reverse $word;
        print qq("$word" reversed is "$mirror"\n);

        %by_address = reverse %by_name;	 # Beware of lost duplicate values
      

        I have the following pets: parrot hamster fish dog cat
        "backwards" reversed is "sdrawkcab"
      
http://stuff.mit.edu/iap/perl/