Author Archives: Andrea Telatin

Tomorrow lesson

Warning - Please be careful  aula C III piano il giorno 6 maggio  dalle ore 14.30 alle ore 16.30

Lab04: welcome back, we missed you

This is the landing page for the fourth laboratory, here at the Paolotti. We missed you!

Remember to keep this page updated regularly, as we are going to put some updates in here.

Continue reading

Tagged

hw6 solution

The problem was:

$seq = ‘GAGTATCTGGAAGACAGGCAGACTTTTCGCCACAGCGTGGTGGTACCTTATGAGCCACCCGAGGCCGGCT’;

use a loop and substr to print its “codons”, one per line.

Continue reading

Tagged ,

A review of Perl hashes…

Some of you had some problems with the exercise on Perl hashes, this is a short review about them. Continue reading

Tagged ,

Lab04: passing arguments to Perl scripts

This post will review how to pass arguments to a Perl script. This is something you can’t test online with codepad (unfortunately), because codepad only runs the script, without emulating a whole system with a shell and files to read…


 

What arguments are

Learning how to play with the Linux shell we understood that each program (or command) can be launched alone, or with parameters. We refer to these parameters as “arguments”.

An example below:

ls
ls -l
ls /usr/bin

The three commands always start with the program to run, but the first only ask the shell to execute the ls program, while the second and the third one also pass some “arguments” to it.

This is a core functionality of any Perl program: its the way we, the user, can ask the Perl program what to do.

How to pass parameters to a Perl script

If we save a Perl script as demo.pl, we know that to launch it we should type (provided that the script is in our current directory):

perl demo.pl

provided that this is the way we launch the command we now want to pass parameters the same way we did with ls, like:

perl demo.pl -l -n ciao

In the line above I gave three parameters to the script. As we cant figure out how many parameter a program needs, Perl stores all the passed arguments into an array, called @ARGV (remember that Perl is case sensitive!!!).

A first example

We are going to create a param1.pl (lab04 folder, of course) program that prints the first parameter you passed to it. It’s very simple:

print "The first parameter is $ARGV[0].\n";

It’s your turn now hw4.1

Now create a script that will print all the parameters passed, not just the first. Save it as params.pl in the lab04 folder.

We want to print one parameter per line, like “The parameter is …“, and at the end it will print “You passed # total parameters“.

Submit it as usual, using hw4.1 as code.

 

Tagged

Reading a file from Perl

This post explains how to read a file from Perl. This is an optional part of laboratory04, so don’t try this unless you really feel confident about all the rest.

Continue reading

Tagged , ,

hw2 solution

This post shows the solution for the homework coded hw2.
Continue reading

Tagged ,

hw1 solution

This is the solution to the first homework.

Continue reading

Tagged ,

Homework: reviewing Perl basics

Review homework (hw3)

If you have Linux on your laptop you can download the program and change it with a text editor like we did in the lab. Note that your Linux may be a little different, so you may need to looks for the Terminal and the Text Editor, but they are there somewhere. If you do not have Linux yet, you can use codepad. This task is codedhw3” (not hw-3 or hw-03…. right?).

Continue reading

Tagged

Homeworks: testing conditions

IF homework (hw1)

This is the first official homework you get! In this homework we are going to do some simple changes to a perl program, like we did during the last lab session.

If you have Linux on your laptop you can download the program and change it with a text editor like we did in the lab. Note that your Linux may be a little different, so you may need to looks for the Terminal and the Text Editor, but they are there somewhere. If you do not have Linux yet, you can use codepad. This task is coded “hw1“.

Continue reading

Tagged ,