Index of /examples/perl/examples/ex04-column-data

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [   ] twocol.pl 19-Mar-2014 10:50 428

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.

Two Columns Example Script

This script demonstrates how to take the output of a command which generates columnar data and extract, for example, the first two columns only. Perl is very commonly used for parsing and manipulating textual data.

The code is commented and can be executed by running the following commands:

    scc1% cd /project/scv/examples/perl/examples/ex04-column-data
    scc1% who | twocol.pl
and the first few lines of output will look like (for example):

amamonov pts/0
goldbe pts/2
mmasia pts/3
edytam pts/4
kadin pts/6
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.