Index of /examples/perl/examples/ex03-sorting

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [   ] 19-Mar-2014 09:58 630

RCS examples

RCS examples are provided to assist you in learning the software and the development of your applications on the SCC machines. The instructions provided along with the code assume that the underlying OS is Linux. If these examples are run on a different architecture, the user might need to make some changes to the code and/or the way the program is built and executed.

Perl Code Notes

All Perl code examples on the SCC must include as the first line #!/usr/local/bin/perl which is a special line with the characters #! followed by the path on the system to the Perl executable. If you copy an example to another machine, you may have to edit this line based on where Perl is installed on your system. Perl programs must also have the execute bit set in order to run (done via chmod u+x executable_name).

Other than this special line, any line or part of a line that follows the number sign # character will be treated as a comment.

Sorting Arrays Example Script

This script shows some basic instances of how one sorts arrays, in particular the difference between sorting by the default dictionary (text) order versus numerical order.

The code documents the differences and if you execute it by running the following commands:

    scc1% cd /project/scv/examples/perl/examples/ex03-sorting
then it will output:

array elements 333 27 250 14
array sorted in dictionary order 14 250 27 333
array elements sorted in numerical order 14 27 250 333

Note: Research Computing Services (RCS) example programs are provided "as is" without any warranty of any kind. The user assumes the entire risk of quality, performance, and repair of any defects. You are encouraged to copy and modify any of the given examples for your own use.