The distinctive Perl camel is (c) O'Reilly
Perl Workshop Home Page
Home of the Bioinformatics Perl Workshop perl workshop > courses > introduction to perl (1.0.1.8) > More String Manipulation (.7/8) > match-02 (.c2)

course 1.0.1.8

Level: beginner
1.0.1.8.7
replacement operator; global matching; context behaviour of match operator

legend

course code

cat.course.level.sessions.session

e.g. 1.0.1.8

categories

0 | introduction and orientation

1 | perl fundamentals

2 | shell and prompt tools

3 | web development

4 | CPAN Modules

5 | Ruby

levels

level: all all ( 0 )

level: beginner beginner ( 1 )

level: intermediate intermediate ( 2 )

level: advanced advanced ( 3 )

[ the code for a course follows the convention category.id.level.sessions and uniquely identifies a course ]

lecture code viewer

downloads

Code
More String Manipulation
More String Manipulation
Martin Krzywinski
#!/home/martink/bin/perl $\ = "\n"; $seq = make_sequence(bp=>"agtc",len=>1000); while($seq =~ /(at.gc)/g) { $match = $1; $matchpos = pos $seq; print "matched $match at ",$matchpos-5," around ",substr($seq,$matchpos-7,10); } sub make_sequence { %args = @_; @bp = split("",$args{bp}); $seq = ""; for (1..$args{len}) { $seq .= $bp[rand(@bp)]; } return $seq; }

7 | More String Manipulation | 1.0.1.8.7

1.0.1.8.7.c1 | match-01 | Martin Krzywinski | code
1.0.1.8.7.c2 | match-02 | Martin Krzywinski | code
1.0.1.8.7.c3 | match-03 | Martin Krzywinski | code
1.0.1.8.7.c4 | replace-01 | Martin Krzywinski | code
1.0.1.8.7.c5 | replace-02 | Martin Krzywinski | code
1.0.1.8.7.c6 | replace-03 | Martin Krzywinski | code
1.0.1.8.7.c7 | substr | Martin Krzywinski | code
1.0.1.8.7.c8 | tr-01 | Martin Krzywinski | code
1.0.1.8.7.a1 | More String Manipulation | Martin Krzywinski | pdf
1.0.1.8.7.p1 | More String Manipulation | Martin Krzywinski | ppt
1.0.1.8.7.s1 | More String Manipulation | Martin Krzywinski | slides