title: Undefined subroutines &main error in Perl
body: <p>I am trying to extract a DNA sequence from this FASTA file to a specified length of bases per line, say 40.</p>
  
  <pre><code>&gt; sample dna  (This is a typical fasta header.)
  agatggcggcgctgaggggtcttgggggctctaggccggccacctactgg
  tttgcagcggagacgacgcatggggcctgcgcaataggagtacgctgcct
  gggaggcgtgactagaagcggaagtagttgtgggcgcctttgcaaccgcc
  tgggacgccgccgagtggtctgtgcaggttcgcgggtcgctggcgggggt
  </code></pre>
  
  <p>Using this Perl module (fasta.pm):</p>
  
  <pre><code>package fasta;
  use strict;
  
  sub read_fasta ($filename) {
      my $filename = @_;
      open (my $FH_IN, "&lt;", $filename) or die "Can't open file: $filename $!";
      my @lines = &lt;$FH_IN&gt;;
      chomp @lines;
      return @lines;
  }
  
  sub read_seq (\@lines) {
      my $linesRef = @_;
      my @lines = @{$linesRef};
      my @seq;
      foreach my $line (@lines) {
          if ($line!~ /^&gt;/) {
              print "$line\n";
              push (@seq, $line);
          }
      }
      return @seq;
  }
  
  sub print_seq_40 (\@seq) {
      my $linesRef = @_;
      my @lines = @{$linesRef};
      my $seq;
      foreach my $line (@lines) {
          $seq = $seq.$line;
      }
  
      my $i= 0;
      my $seq_line;
      while (($i+1)*40 &lt; length ($seq)) {
          my $seq_line = substr ($seq, $i*40, 40);
          print "$seq_line\n";
          $i++;
      }
      $seq_line = substr ($seq, $i*40);
      print "$seq_line\n";
  }
  1;
  </code></pre>
  
  <p>And the main script is</p>
  
  <pre><code>use strict;
  use warnings;
  use fasta;
  
  print "What is your filename: ";
  my $filename = &lt;STDIN&gt;;
  chomp $filename;
  
  my @lines = read_fasta ($filename);
  my @seq = read_seq (\@lines);
  print_seq_40 (\@seq);
  exit;
  </code></pre>
  
  <p>This is the error I get</p>
  
  <pre><code>Undefined subroutine &amp;main::read_fasta called at q2.pl line 13, &lt;STDIN&gt; line 1.
  </code></pre>
  
  <p>Can anyone please enlighten me on which part I did wrong?</p>