up
Perl Lecture Notes - April 12 2002
- Meta-Programming
Things to think about beyond the code itself
- Testing
- Code the Unit Test First
- Perl's test protocol
- Version control (i.e. CVS)
- keep track of versions and changes to your code
- one way : CVS
- Concurrent Versions System
- cvs notes on
how to add a project of yours to a cvs server on bob
- Documentation
- readme.txt - an overview of what's what
- POD - interface , or how to invoke it
- implementation - comments within code
- Installation
- develop vs deploy
- perl scripts to automate copying, setting privileges, etc.
- Putting it all together to test a cgi script :
RegistrarSchedule example
- run it
- implementation:
- CPAN Storable.pm for data persistence,
- CGI.pm handles parameters passed,
- single .cgi file with html embedded in long strings
- cvs repository RegistrarSchedule in bob /home/cvs/msie02
- source - MarlboroClassSchedule.cgi
- test.pl
- install.pl
- readme.txt
- Writing CPAN-style Perl Modules ...
by letting h2xs do all the set up for you.
- Inline C
Putting C code (or Java,Python,Ruby,assembler...) into your Perl source
- perl and C code
- rounding off numbers
- How it works:
- Parses C code to find arguments. (Parse::RecDescent)
- Stores all the XS stuff in a .Inline or _Inline directory.
- C compilation is slow -
but only recompiles if C source changes. (Uses an MD5 hash.)
- But wait, there's more!
- perl to C, Java, and Python in one file:
inline_demo.pl
- It slices! It dices!
- another java example:
Pantry.pl
- Windows "alert" box from their system library.
Inline C Cookbook: Win23 alert
- The Inline API
- What the Inline.pm module really gives you
is a general interface to something else from perl.
Several people have now put a number of other languages
in - even assembler.
- Inline-API
- how to add the language of your choice
- Even Inline::Perl
(Not quite as stupid as it sounds,
since you could have Inline::Perl-4.0,
from within Perl-5.6.)
- A real example - VectorDouble.pm
- a perl object to manipulate arrays of double-precision numbers.
Fast, because the real work is done in C.
- documentation
- source code
- I worked on this last year, thinking about how to do numeric work from perl.
- To see it run, do "perl VectorDouble.pm".
- To see the documentation,
do "perldoc VectorDouble.pm" or
"pod2html VectorDouble.pm > VectorDouble.html".
- Resources
- perl unit testing
- CVS
- home
- book - Open Source Development with CVS (chapters explaining CVS are online)
- Inline
- Assignment
- Work on your capstones,
- And think about incorporating some of this stuff in 'em.
See you in the third trimester, eh?