Web Coding in Perl
Perl code files can consist of nothing but Perl code. They can't have straight text or HTML tags like PHP files can. All straight text or HTML tags need to be printed using print() statements or other printing mechanisms.
Fortunately, Perl has the print <<end; syntax, which allows us to embed straight text within a kind of comment inside the Perl code.
I also wrote a subroutine to include a file (the sidebar) within the code as a kind of include file. Perl doesn't make this kind of a function available by default, but it is easy to write one.
To make the CGI work, I needed to add this .htaccess file:
OPTIONS Indexes AddHandler cgi-script .pl Options +ExecCGI
It took me a while to get the DBI and DBD modules working on my home computer. Eventually, I did it using Cpann. I used the instructions on this page starting at the section that says Install Perlbrew then Install Perl modules. The big secret is running everthing with sudo so it gets put in the right place completely.
curl -L http://install.perlbrew.pl | bash echo 'source /perl5/perlbrew/etc/bashrc' >> ~/.bash_profile sudo perlbrew install --notest --as 5.14.4 --thread --64all \ -Duseshrplib perl-5.14.4 sudo perlbrew install-cpanm sudo cpanm DBI sudo cpanm Test::Differences Test::Exception Test::Perl::Critic sudo cpanm DBD::mysql sudo cpanm HTML::Entities Archive::Zip IPC::Run Crypt::DSA \ Crypt::SSLeay XML::Parser XML::Atom Mail::Sendmail \ Net::SMTP::TLS Net::SMTP::SSL Imager
Useful links
- Basename
- Foreach
- Writing Perl Modules
- Including files
- fetchrow_array
- CPAN CGI Session Tutorial
- Example: using the DATA file handle
- Perl Functions A-Z
- Enable CGI outside of cgi-bin
- Beginning Perl (free book online)
- CGI Programming 101
- Pushing multi-dimensional arrays onto each other
- Sorting a two dimensional array
- Sorting arrays with a custom function
- Installing Perl, DBD::mysql and Ensembl on OSX