Exercises, examples and other material relating to training module P669. This topic is presented on public course
Perl for Larger Projects
Perl is a superb language for data manipulation. This module covers some of the more advanced features of the language which help give it this capability.
Related technical and longer articles
Data Monging
Articles and tips on this subject | updated |
4620 | Perl 6 - a Practical Extraction and Reporting example! Always looking for an excuse to write little demo scripts - especially in Perl 6 which was new as an official release at Christmas, ... and had such an opportunity today. A datafile containing 2,500 records - station usage - and seeing how many were smaller in passenger numbers that Melksham in 2014 ... | 2016-01-12 |
3764 | Shell, Awk, Perl of Python? Very frequently, IT system users find they've got a data file in one format and they need to filter it and transform it. On Linux and Unix systems, utilities such as grep and cut were the tradtions, perhaps with some awk.
Perl provided a single-program replacement for shell scripts that bolted together ... | 2012-06-16 |
3707 | Converting codons via Amino Acids to Proteins in Perl DNA is the code of life - a double helix, comprising just four different basic codon elements:
• Adenine (A)
• Thymine (T)
• Guanine (G)
• Cytosine (c)
and a huge amount of work has gone into analysing these for the genes right across ... | 2012-04-28 |
3335 | Practical Extraction and Reporting The week just gone, I gave a Perl course in Edinburgh to a dozen very bright scientists, working in the bionformatics field, where they're concerned with analysing a veritable flood of data. A great deal of that analysis is fairly standard and so will be done using standard tools - some written in C ... | 2011-06-26 (longer) |
2702 | First and last match with Regular Expressions Conventional Wisdom says that it's pointless to start a regular expression with ".*" or ".+", as this is implied within a match - regular expression matches are looking for strings that are contained anyway:
'/abc/' - contains abc
'/.*abc/' - contains anything or nothing, followed by abc
However - ... | 2010-04-02 |
2129 | Nothing beats Perl to solve a data manipulation requirement quickly OK - I admit it. It might be slightly out of fashion but I still love Perl for that quick hack script which is a one-off data manipulation need.
I have two files - the first containing records of who signed our pledge for an appropriate TransWilts train service last year, and another containing records ... | 2009-04-16 |
1947 | Perl substitute - the e modifier Here's a graphic illustration of the use of the "e" for "execute" modifier used on the end of substitute operation in Perl.
The "s" for substitute allows you to replace a matched pattern with a STRING in which you can use special references like \1 or $1 for the first matched substring. If you want ... | 2008-12-16 |
1509 | Extracting information from a file of records Here's a very common application ...
You file a file of data records, and you want to parse the file handing the data record by record. Each record has a series of space delimited fields, most of which are no interest to you what so ever ...
And a template for a solution in Perl.
open (FH,--put ... | 2008-01-17 |
1316 | Filtering and altering Perl lists with grep and map In Perl, you can process whole lists (arrays) in single operations - and that's very efficient at run time as it avoids the needs for loops, and the needed for Perl's Virtual Machine to go back to the byte code (in effect source) for each member.
The map function applies an opertion to each member of ... | 2007-08-23 |
597 | Storing a regular expression in a perl variable When you match to a regular expression in a perl program, the program has to compile the regular expression (i.e. work out what it does) before actually doing the matching. It's pretty smart about that - it stored the result of than compile so that it only has to do it once during each run. However, ... | 2006-06-05 |
Examples from our training material
anagram | Perl program to look for anagrams |
bacon | Conversion Codons -> Amino Acids -> Protein |
cdk.fasta | Data for sample bioinformatics program in Perl |
filedata | List manipulation - sorting files by size and reporting largest 10 |
filedata2 | Sorting files by size - shortened example, harder to follow? |
memsave | Compressing data to save memory |
new1 | List iteration |
new2 | Alternative list iteration |
oldfash | Handling an "arraY" - really a list - the oldfashioned way |
pc1 | (Somewhat) conventional programming methods to parse data |
pc2 | Using the power of lists to save code and time |
pc3 | Handling a file as a single string of text |
Pictures
Examining the output of a Perl program
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
[here].
Topics covered in this module
Iterating over data in Perl.
Processing data through regular expressions.
Compressing data.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.