Your OPed question has been well and truly answered. Here are some general comments on your posted code.

In sum, I might have written the program as follows. Again, many of the programming choices represent personal preferences; take them as you find them.

use warnings; use strict; my $usage = <<"EOT"; usage: perl $0 dna_datafile.name EOT die $usage unless @ARGV >= 1; my $filename = $ARGV[0]; my $rx_dna = qr{ \b [ATCGatcg]+ \b }xms; open my $filehandle, '<', $filename or die "opening '$filename': $!"; SEQ: while (my $seq = <$filehandle>) { next SEQ unless my ($dna) = $seq =~ m{ \A ($rx_dna) \s* \z }xms; (my $revcom = reverse $dna) =~ tr/ACGTacgt/TGCAtgca/; print "dna -> reverse complement \n"; print "'$dna' -> '$revcom' \n\n"; } close $filehandle or die "closing '$filename': $!"; exit; # define any subroutines here ######################################## +#
(See autodie to get rid of all the explicit  ... or die "...: $!"; expressions.)

Data file dna.dat:

ACTG catgataaatttccc not dna tgac

Output:

c:\@Work\Perl\monks\undergradguy>perl rev_comp_2.pl dna.dat dna -> reverse complement 'ACTG' -> 'CAGT' dna -> reverse complement 'catgataaatttccc' -> 'gggaaatttatcatg' dna -> reverse complement 'tgac' -> 'gtca'
The next step: Put the reverse complement functions into a  .pm module with an accompanying Test::More  .t file. :)

Update 1: It's true that  -w on the command line enables warnings globally (see  $^W special variable in perlvar). However,  -Mstrict on the command line still only has lexical scope, in this case the scope of the code in the  -e "..." switch. Given a module Unstrict.pm

# Unstrict.pm 22dec18waw package Unstrict; # use strict; # module will not compile with strictures enabled $string = bareword; sub func { return $string; } 1;
consider
c:\@Work\Perl\monks\undergradguy>perl -Mstrict -le "use Unstrict; print Unstrict::func(); " bareword c:\@Work\Perl\monks\undergradguy>perl -Mstrict -le "use Unstrict; print Unstrict::func(), $x; " Global symbol "$x" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors. c:\@Work\Perl\monks\undergradguy>perl -wMstrict -le "use Unstrict; print Unstrict::func(); " Unquoted string "bareword" may clash with future reserved word at Unst +rict.pm line 7. bareword


Give a man a fish:  <%-{-{-{-<


In reply to Re: Isolating DNA cont. by AnomalousMonk
in thread Isolating DNA cont. by undergradguy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.