Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1. A copy of the license is included in the section entitled “GNU Free Documentation License”
- Introduction
- Introduction in Perls Before Swine
- The basic Perl filter
- Make sure you’ve downloaded the sample data, and then create the following text file:
- Smarter scripts
- Smarter scripts in Perls Before Swine
- Arrays and functions
- We’ve done a little bit with an array already: the list of arguments to the script is a simple array. We’ve only ever referenced the first item in that array, shifting that first item out so that the next items is now first. We can do quite a bit more with arrays in Perl.
- Custom search
- Remember that search for “stand” that topped the list with a bunch of older artists? Try that search again without asking for a summary and most of them don’t have “stand” anywhere in the song, artist, or album.
- Creating files
- Unix-like operating systems provide an easy means of creating files from any program that has an output. Often, you won’t even need to worry about creating files, you’ll just redirect to a file and let the operating system handle it for you.
- SQL database
- One of the most common things Perl is used for when it comes to raw data files is importing them into databases. To import into databases in Perl, you need a special module. This is normally the DBI module, and you’ll access it by putting a “use” line at the top of your script. This tells Perl that you want to access an external module for more functionality.
- Perls Before Swine: Web CGIs
- One of the most common uses of Perl on databases is displaying the data in the database on the web. Perl comes with a special module for use as a web page generator, called “CGI”. CGI stands for Common Gateway Interface. It’s a way for web servers to pass data to programs such as Perl scripts. The CGI module makes heavy use of objects and methods. You can find out more about Perl’s CGI module by typing “perldoc CGI” from a Unix command line.
- Perls Before Swine: Reference
- Reference in Perls Before Swine
- More Information
- The Perl web site at http://www.perl.org/ has documentation, tutorials, and links to several wonderful resources. O’Reilly has several very useful books about Perl. “Learning Perl” and “Programming Perl”. Get “Learning Perl” if you need to learn programming, and get “Programming Perl” if you already know programming but want to learn programming in Perl.
- Perls Before Swine (full HTML) (183.1 KB)
- HTML version of Perls Before Swine
- Perls Before Swine (full PDF) (1.5 MB)
- PDF version of Perls Before Swine
- Perls Before Swine (full RTF) (865.7 KB)
- RTF version of Perls Before Swine
- ZIP Resources for Perls Before Swine (958.9 KB)
- Resources for Perls Before Swine, including samples and document graphics.