Perl Tips

This article was written to provide a few Perl tips and examples that can help you quickly edit single or batch data files from a command line.
 
Perl is a general-purpose language that is very powerful at manipulating data files containing text and numbers. Often it is necessary for SeaBASS data submitters or users to search and replace patterns found throughout many text files, which can be very time consuming if you manually open, change and resave each file individually. If you've ever accidentally misformatted a header, or need to get rid of extra spaces at the beginning of every line, or faced some other repetitive task involving search-and-replace, then don't fret; continue reading to learn some simple ways to fix those issues in a single command.
 
Perl is free and is even installed by default on several operating systems (e.g. most Macs). If you don't already have it, it can be downloaded from www.perl.org for most flavors of Windows, Mac and Linux operating systems. Of the options available, Windows users might wish to try Strawberry Perl (though we do not officially endorse any particular version.) Many Perl guides and tutorials already exist on the Internet so the content on this page will focus only on a few tips that are relevant to SeaBASS data. You can accomplish extremely complex tasks by writing longer amounts of code in Perl, but those are beyond the scope of this article. If Perl is new to you then you might also want to read a more comprehensive introduction such as the one found on the official Perl site, but you should be able to get started with the examples below.