#!/usr/bin/perl -w #Usage: shorten_mod_names < file_with_long_mod_names > file_with_short_mod_names while ($line = ) { if ($line =~ /[.]mod/) { @cols = split(" ", $line); # now $cols[0] has the model name, but is it "long" or "short"? # look for at least two periods in the name to identify long names. if ($cols[0] =~ /(\w+)[.]\S+[.]mod/) { # long names look like 1qloA.t2k-w0.5.mod # and we just want to keep the 1q1oA before the first period. $name = $1; } else { $name=$cols[0]; } print join("\t", $name, @cols[1 .. $#cols]) . "\n"; } else { # here we print out the col header and definition lines print $line; } }