6.Perl
We'll introduce Perl here. If you have no previous experience on either Perl or Python, we would recommend Python for you.
Teaching Video: Week III.5.Perl

1) Install Perl Modules

    1.
    2.
    Install modules with cpan
usually you start cpan in your shell:
# cpan
and type
install Statistics::Basic
install Statistics/LineFit.pm
install Math/Cephes.pm
or in short form:
cpan install Statistics::Basic
cpan install Statistics/LineFit.pm
cpan install Math/Cephes.pm

2) Examples

My Perl Scripts at github , for instance:
    seqmanipulator.pl
    snp.pl
    TFtargets.pl
    export_intron.pl
    siRNA-filter-NAR2008.pl

3) Tips

Perl in command line
1
perl -ne 's/aaa/ccc/;print $_' file.in
2
perl -p -i.bak -e 's/aaa/ccc/' file.in
3
perl -pi -e 's/aaa/ccc/' file.in
4
perl -n -e '@line=split(" ",$_);print $line[0] $line[1],"\n"' file.in
Copied!
Syntax checking
perl -cw *.pl
Add perl5lib
in .bashrc:
export PERL5LIB=/home/john/my_perl_lib:/CVS/my_perl_lib
The state of a file
1
use File::stat;
2
$sb = stat($filename);
3
print "$sb->size\n";
Copied!
In a subroutine
my $a = @_;
is illegal to read the input. Must add ( ) to the variable, so it should be
my ($a) = @_;

4) Homework for Perl

    1.
    Try to run my favorite Perl scripts and install the modules needed.

5) Video

@Youtube
@Bilibili
Last modified 3yr ago