Fix this

#!/usr/bin/perl -- # consolidated.pl # 2017-05-13-19:55:06 # # ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for " +-otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*" #!/usr/bin/perl -- use strict; use warnings; Main( @ARGV ); exit( 0 ); sub Main { my $infile = "human_hg19_circRNAs_putative_spliced_sequence.fa"; my( $seq, $id ) = ReadHashSequences( $infile ); my( $min, $max ) = PromptMinMax(); SpecifySeqLengths( $seq, $min, $max ); } sub ReadHashSequences { my( $infile ) = @_; use autodie qw/ open /; open my( $fh ), '<', $infile; my %seq = (); my $id = ''; while( <$fh> ) { chomp; if( $_ =~ /^>(.+)/ ) { $id = $1; } else { $seq{$id} .= $_; } } close $fh; return \%seq, $id; } ## end sub ReadHashSequences sub Prompt { my( $msg, $default ) = @_; ...; return $default; } sub PromptMinMax { my( $def_min, $def_max ) = grep defined, @_, 0, 10; my $min = Prompt( "Enter Max sequence length:", $def_min ); my $max = Prompt( "Enter Min sequence length:", $def_max ); return $min, $max; } sub SpecifySeqLengths { my( $seq, $minlength, $maxlength ) = @_; for my $id ( keys %$seq ) { if( ( length $seq->{$id} <= $maxlength ) && ( length $seq->{$id} >= $minlength ) ) { PunchFile( "SeqLength_$minlength-$maxlength", $id, $seq->{ +$id} ); } } } ## end sub SpecifySeqLengths sub PunchFile { my( $newfile, $id, $val ) = @_; if( -f $id ) { print $id, " already exists. It is about to be overwritten\n"; } use autodie qw/ open /; open my( $newfh ), '>>', $newfile; print $newfh $id, "\n", $val, "\n"; close $newfh; } ## end sub PunchFile __END__ $ perl consolidated.pl Can't open 'human_hg19_circRNAs_putative_spliced_sequence.fa' for read +ing: 'No such file or directory' at consolidated.p l line 23

In reply to Re: I'm trying to consolidate my functions into subroutines by Anonymous Monk
in thread I'm trying to consolidate my functions into subroutines by Peter Keystrokes

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.