#!/usr/bin/perl use strict; use warnings; #modified from Dustin MAIN: { my $seq=''; my $revcomp=''; print "Please enter sequence to be reverse complemented\n"; chomp($seq=<>); $revcomp=&Reverse(&Complement($seq)); #Next line would work just as well # $revcomp=Reverse(Complement($seq)); print "\n"; print "The reverse complement of \$seq=$seq"." is"." $revcomp\n\n"; exit;} sub Reverse { use strict; use warnings; my $string = $_[0]; my $rev= reverse $string; return $rev; } sub Complement{ # you can use a local variable with the same name as in the main program e.g. my $seq= $_[0]; $seq =~ tr/ATGCYRatcgyr/TACGRYTAGCRY/; return ($seq); #$seq in the calling program is not impacted. #my$comp= $_[0]; #$comp =~ tr/ATGCYRatcgyr/TACGRYTAGCRY/; #return $comp; }