Perl

by

The following Perl script uses regular expressions to parse a text file called myFile.txt and replace any occurrence of the character sequence REPLACE with the string (or number) stored in $NEWTEXT. The modified text file is saved as myNewFile.txt. #!/usr/bin/perl $NEWTEXT = “New Stuff”; # could also be a number open(INPUT, “< myFile.txt") or die

by

The code below demonstrates a short Perl function that takes an array as an argument and returns the average of this array. #!/usr/bin/perl sub average { my @array = @_; # save the array passed to this function my $sum; # create a variable to hold the sum of the array’s values foreach (@array) {

by

The code below presents the basic structure of a Perl script that reads the columns of a tab-delineated text file and saves each column to a separate data array that can then be used to for additional processing. The code is set up to process a data file with two columns of data (x and