title: How to create a sliding window and put the values of the sliding window into a hash?
body: <p>I needed to create a sliding window of size 15, go through a Fasta file and store all of the values of the sliding window into a hash. When I try to print I get the error</p>
  
  <blockquote>
    <p>Global symbol "$sequence" requires explicit package name at ./findAllKmers.1.pl line 60.<br>
    Execution of ./findAllKmers.1.pl aborted due to compilation errors"</p>
  </blockquote>
  
  <pre class="lang-perl prettyprint-override"><code>#!/usr/bin/perl
  use warnings;
  use strict;
  
  my %windowSeqScores = ();
  
  my $sequenceRef = loadSequence("/scratch/Drosophila/dmel-2L-chromosome-r5.54.fasta");  
  my $windowSize = 23;
  my $stepSize = 1;
  my $maxScore = 0;
  my $sequence = @_; 
  my $in_file = 'uniqueKmersEndingGG.fasta';
  
  open (my $fh, '&gt;', $in_file) or die "Could not open file 'filename' $!";
  
  for (
      my $windowStart = 0;
      $windowStart &lt;= (length($$sequenceRef) - $windowSize);
      $windowStart += $stepSize
  )
  {
      my $windowSeq = substr($$sequenceRef, $windowStart, $windowSize);
      sub loadSequence {
          my ($sequenceFile) = @_;
          my $sequence = "";
          my $counter = 0;
          unless (open(FASTA, "&lt;", $sequenceFile)) {
              die $!;
          }
  
          while (&lt;FASTA&gt;) {
              my $line = $_;
              chomp($line);
              if ($line !~ /^&gt;/) {
                  my $sequence = $line;
                  if (length($sequence) == 15) {
                  $counter = $counter + 1;
                  print $_;
              }
          }
          return \$sequence;
      }
  }
  print $sequence;
  </code></pre>