#!/usr/bin/perl use strict; use warnings; open my $file, '<', "file.txt" or die $!; open my $out, '>', "newfile.txt" or die $!; for (1..2) { my $constant = <$file>; print $out $constant; } while (<$file>) { my ($name, $time) = (split /\s+/, $file)[1,9]; my ($net, $sta) = (split /\s+/, $name)[0,1]; if ($net eq "ZJ") { } # Calculate the mean of the 9th column for every first column that begins with ZJ, # and subtract the mean from each value (time) in the 9th column. } # Output the new file with the mean removed from each "time" in the 9th column