No textbook required. Recommended: see samples.

Online books are here (very wordy, pdf), here (more concise), and here (good to look up things, navigation not very useful to read "cover to cover").

Reading assignments will be posted or handed out.

Usually, class is reserved for discussion and problem solving not frontal lectures

Accounts on cluster: UNIX is case sensitive (although the MAC version often tries to make a gues on what you might mean). After you login, change your password. To do so, type passwd at the command line prompt, and follow instructions. Please use a somewhat complex password to protect the system.

Send programs and assignments to
Gogarten@uconn.edu Ê

Grades will be based on submitted assignments, and on the independent student project.

Independent project: By the middle of the semester you should discuss your project with the instructor.
Possibilities include:

 

IMPORTANT

Use unix/ linux /OsX if possible.

A) open a terminal window ; type "which perl <return>"
B) SSH to a unix machine (cluster OsX), log in, type "which perl <return>"
C) to check the version type perl -v <return>

The response of the system should tell you, where Perl is installed on your machine (you need to know this for the first line of your perl program, which tells the operating system how to interpret what follows. On most installations this is #!/usr/bin/perl ).

WINDOWS: If you use a windows machine, you can use an ssh program to connect to the biotech cluster. A good ssh client is available at ftp://ftp.ssh.com/pub/ssh/- highly recommended. I am sure that there are editors available that are more useful than notepad, but I don't know of them. :(

MAC OsX: If you use a Mac under OS X, and you do not want to (only) use the PERL locally, you want to install both jellyfish (ssh terminal) and fugu (a secure file transfer program). Both are available at ftp://ftp.uconn.edu/pub/packages/ssh/mac/ or through the people who wrote the software - GOOGLE)
Also, the bbcxsrv1 is available as a server using ssh or apl. You can connect to to it from the finder menu (-> GO -> Connect to Server) pasting the following into the menu box afp://bbcxsrv1.biotech.uconn.edu (select your account).

LINUX: Most editors on linux systems recognize Perl programs and provide context dependent coloring. Ssh and Konquerer work well for file transfer.

 

Less important: If for whatever strange reason, you want to install PERL under windows, install active PERL from active state -- most other operating systems already come with PERL installed! A reasonable manual to do so is here

Less important: Where to get the latest version of Perl.Ê http://cpan.org/

Basic UNIX commands
ls, cd, chmod, cp, rm, mkdir, more (or) less, vi, ps, kill Ð9, man

Brief listing at http://carrot.mcb.uconn.edu/mcb372/old/UNIXCOMM.htm

chmod is a particular pain in the ... . Under unix every file has an owner and the owner, his group and everyone else have permissions to read, write and execute the file. If you want to see which permissions are currently assigned to your files, type ls -l at the command prompt. chmod a+x *.pl gives everyone execute permission for all files that end with .pl the * is a wildcard. (warning don't ever use rm in conjunction with *)
For more on chmod type  man chmod or see here.
(In the OSX GUI you can control click at a file, and change permissions in the info box). Most ssh clients (FUGU and SSH) allow you to use a GUI to change file permissions (in FUGU ctrl click)

MORE IMPORTANT:

Files from Windows to UNIX and return: End of Line characters are a problem.

Under Windows DO NOT use notepad, it does not understand UNIX newline symbols.

Best write your programs under UNIX using vi or vim (or any other editor you are comfortable with)

2nd best is to use a text editor like textwrangler (very nice and free program for UNIX). Like vi and vim it provides context dependent coloring.

3rd best is to remove end of line symbols in a UNIX editor or use sed (Stream EDitor) after you transferred the file:
sed s/.$// name_of_WINDOWS_infile > name_of_UNIX_outfile
Some versions of office allow to change files as UNIX textfiles, but ...

A related problem is encountered by Mac users. Most text editors will use MAC carriage returns at the end of the line. Most unix programs will not be able to handle these. In a terminal window you could use the following command to convert your file:
tr '\r' '\n' < name_of_the_Mac_file > name_of_the_unix_file
If you are working in a GUI environment, you also could use the convertNewLines.app program (install it in your application folder, drag the file you want to convert into the icon). the program is available here.

This is very inconvenient, but there is really no easy solution, tough luck; and you better know about this incase something goes wrong.

=====================================================

One way to write and edit programs is directly under unix using the vi editor. You invoke the editor by typing vi followed by the name of the program to open.

vi myprogram.pl

A short introduction to vi is at http://goforit.unk.edu/unix/unix11.htm -- however, if you run into problems google usually helps (e.g. google: vi replace unix gives you many pages of info on how to replace one string with another under vi)

The following should get you started:

The arrow keys move the cursor in the text
(if you have a really dumb terminal you can use the letter hjkl to move the cursor)

x deletes the character under the cursor

esc (i.e. the escape key) leaves the edit mode

i enters the edit mode and inserts before the cursor

a enters the edit mode and appends

esc : opens a command line (here you can start searches, and replacements)

:w #saves the file

:w new_name _of_file #writes the file into a new file.

:wq #saves the file and exits vi

:q! #exits vi without saving

One of the beauties of vi is that usually it provides context dependent coloring. You need to tell vi which terminal you use. One way to do so is to add a file called .vimrc to your home directory.

The following works under both, MAS OSX and using ssh via the secure shell program under windows:

vi .vimrc #opens vi to edit .vimrc (files that start with a dot are not listed if you list a directory. List with ls -a )

set term=xterm-color #tells the editor that you use a terminal that conforms to some standard

syn on # tells the editor program that you want to use syntax dependent coloring.

esc

:wq

This might seem a little inconvenient, but it really comes in handy to trouble shoot the program in the same environment where you want to run it.

(comment on textwrangler alternative, ssh is included inside the grogram)

 

===========================================================

PERL conventions and rules

Basic Perl Punctuation line ends with Ò;Ó

empty lines in program are ignored

comments start with #

first line points to path to interpreter

#! /usr/bin/perl
# "#!" is known as "shebang"

keep one command per line for readability
use indentation do show program blocks.

operators for basic arithmetic (Tab2.2, page 17)

Variables start with $calars, @rrays, or %ashes

Data Types: Intergers, strings, floating points, arrays

Scalars:
       types: foating point numbers, integers, else: non decimal integers (octal, hexadecimal) -
                      example -1.2E-23 same as 1.2e-23
                 strings

Numbers can be manipulated using the typical symbols:

2 + 3 # 2 plus 3, or 5
5.1 - 2.4 # 5.1 minus 2.4, or approximately 2.7;
3 * 12 # 3 times 12 = 36;
2**3 # 2 taken to the third power = 2*2*2 = 8
14 / 2 # 14
divided by 2, or 7;
10.2 / 0.3 # 10.2 divided by 0.3, or approximately 34;
10 / 3 # always floating point divide, so approximately 3.3333333...

Special characters:

\n #newline
\t #tab Ê

Variable interpolation - single quoted strings are not interpolated:

'hello' # five characters: h, e, l, l, o
'don\'t' # five characters: d, o, n, single-quote, t
'' # the null string (no characters)
'silly\\me' # silly, followed by backslash, followed by me
'hello\n' # hello followed by backslash followed by n
'hello
there' # hello, newline, there (11 characters total)

Double quoted strings are interpolated:

"hello world\n" # hello world, and a newline
"new \177" # new, space, and the delete character (octal 177)
"coke\tsprite" # a coke, a tab, and a sprite

The backslash can precede many different characters to mean different things (typically called a backslash escape).

Scalar variable are placeholders that can be assigned a scalar value (either number or string). Scalar variables begin with $

$n=3; #assigns the numerical value 3 to the variable $n. Variables are interpolated, for example if you print text

Note: these are not mathematical equations but assignments!

$b = 4 + ($a = 3); # assign 3 to $a, then add 4 to that
# resulting in $b getting 7
$d = ($c = 5); # copy 5 into $c, and then also into $d
$d = $c = 5; # the same thing without parentheses

$a = $a + 5; # without the binary assignment operator
$a += 5; # with the binary assignment operator

$str = $str . " "; # append a space to $str
$str .= " "; # same thing with assignment operator

"hello" . "world" # same as "helloworld"
'hello world' . "\n" # same as "hello world\n"
"fred" . " " . "barney" # same as "fred barney"
"fred" x 3 # is "fredfredfred"
"barney" x (4+1) # is "barney" x 5, or # "barneybarneybarneybarneybarney"
(3+2) x 4 # is 5 x 4, or really "5" x 4, which is "5555"

Assignments:

If you are stuck, send an email with description of your problem.