I'm trying to implement a subroutine that calculates the d-neighbors of an input string. This is apart of an implementation of planted motif search, but my question is much more general. Here is the code:
#subroutine for generating d-neighbors
sub generate_d_neighbors{
# $sequence is the sequence to generate d-neighbors from
# $HD is the Hamming Distance
my ($sequence, $HD) = @_;
for(my $i = 0; $i=$HD; $i++){
my @l = ['A', 'C', 'T', 'G'];
my @t = splice(@l,$sequence[$i]);
#TODO
}
}
The error is occurring at the last line, saying that:
Global symbol "@sequence" requires explicit package name (did you forget to declare "my @sequence"?
It was my understanding that Perl does not take parameters in the form subroutine(param1, param2)
like in Java for example, but why is $sequence
not being recognized as already having been initialized?