#!/usr/bin/perl -w ###############INPUT#################### #input sequence; chomp every line, and concatenate into one big scalar called $seq unless(@ARGV==1) {die "please provide name of the file in the command line!!\n";} $filename=$ARGV[0]; open(IN, "< $filename") or die "cannot open $filename:$!"; $seq=''; while(defined($line=)){ chomp($line); $seq .= $line ; } # print "input sequence is \n $seq\n"; #make sure sequence is read accurately ########### END INPUT######################### ####Program: call sub and print output $invcomp=&RevComp($seq);#call subroutine, hand over content of $seq as parameter # the result of the suroutines operation will be assigned to $invcomp print "\n\n\ninverse complement is \n$invcomp\n"; #print output ########End Program############### #### Sub: sub RevComp { my ($DNAseq, $rev, $rev_comp);# 'local' variables # print "subroutine RevComp was called\n"; #make sure sub is called $DNAseq=$_[0]; # print "subroutine is working on \n $DNAseq\n";# make sure sub got the right sequence $rev = reverse $DNAseq; $rev_comp=$rev; $rev_comp =~ tr/atgcATGC/TACGTACG/; $rev_comp; # returns contents of this variable to the main program - might be superfluous- NOT else the result is the number of tranlations made };