1 / 9

Lecture 9:

Lecture 9: . Basic concepts of Perl Modules. Functions (Subs). In perl functions take the following format: sub subname { my $var1 = $_[0]; statements Return value } After all the subs are defined they are then called as required: my $variable = subname ($name);

coye
Download Presentation

Lecture 9:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 9: Basic concepts of Perl Modules

  2. Functions (Subs) • In perl functions take the following format: • sub subname • { • my $var1 = $_[0]; • statements • Return value • } • After all the subs are defined they are then called as required: • my $variable = subname($name); • The SubroutineExample.pl

  3. Perl Modules (.pm) • A perl module is a set of functions stored in a separate file (example.pm) which can be used by any perl script. (increase re-usability) • It is sometimes referred to as a library (like stdio.h) or package • There is two files assoicated with using modules. A .pm file and a .pl file

  4. A Simple perl module • #!/usr/bin/perl • package Foo; • sub bar • { • print "Hello $_[0]\n" • } • sub blat • { • print "World $_[0]\n" • } • 1;

  5. Utilising a perl Module • A perl module can be invoked (loaded) in a perl script by using • require and then :: function_name • use and qw( parameter list) • Loading with require: • #!/usr/bin/perl • requireFoo; # used to load the perl module • Foo::bar( "a" ); • Foo::blat( "b" );

  6. Utilising a perl module • A perl module can also be loaded with use and by passing parameters via qw; e.g. • #!/usr/bin/perl • useFooUse; • bar( "a" ); # no need to use :: • blat( "b" ); • However must use qw to utilise the module • require Exporter; • @ISA = qw(Exporter); • @EXPORT = qw(bar blat);

  7. Modified Perl module for “use” • package FooUse; • require Exporter; • @ISA = qw(Exporter); • @EXPORT = qw(bar blat); • sub bar { print "Hello $_[0]\n" } • sub blat { print "World $_[0]\n" } • sub splat { print "Not $_[0]\n" } # Not exported! • 1;

  8. Exercise • Create and run the perl modules covered in class. • Modify the use perl script to see What happens if I call the splat function? • Re-write the “ByReference” subroutine in the pass by reference example (in the subroutine lecture) as a perl module and load it in a perl script. • Re-write your assignment perl scripts in the form of a perl module and a perl script driver.

  9. Class Exercise: Finding start and stop codons and potential ORF • Download the file. (TUBAC3 gene complete sequence) (see last lecture) • Using “your” perl module and perl script determine the location of the start and stop codons. • Write a script that will “attempt” to find at least one ORF. Clearly state how, using your background knowledge of gene expression, you are going to try and resolve this problem. • Using your program: determine the position of an (the) ORF(s) for this gene. • Discuss How your findings compare with the results obtained in the genebank record file .

More Related