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
Global symbol "$sequence" requires explicit package name at ./findAllKmers.1.pl line 60.
Execution of ./findAllKmers.1.pl aborted due to compilation errors"
#!/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, '>', $in_file) or die "Could not open file 'filename' $!";
for (
my $windowStart = 0;
$windowStart <= (length($$sequenceRef) - $windowSize);
$windowStart += $stepSize
)
{
my $windowSeq = substr($$sequenceRef, $windowStart, $windowSize);
sub loadSequence {
my ($sequenceFile) = @_;
my $sequence = "";
my $counter = 0;
unless (open(FASTA, "<", $sequenceFile)) {
die $!;
}
while (<FASTA>) {
my $line = $_;
chomp($line);
if ($line !~ /^>/) {
my $sequence = $line;
if (length($sequence) == 15) {
$counter = $counter + 1;
print $_;
}
}
return \$sequence;
}
}
print $sequence;