DanielM0412 has asked for the wisdom of the Perl Monks concerning the following question:
ive researched about shift, but only found broad answers that were no help, i cant avoid not understanding shift because it pops up everywhere!!
also, my friend pat showed me a sliding window for a long file, to find Xcharacter patterns,( it would look somethin like this) ACGTTGCAAGCTGTAAA, and there are a couple places are confusing me, help me? :) code is below, thanks in advance
sub getXCharacterPatterns{ my $str=shift; #what does shift do here? my $pl=shift; #andd here my $slen=length($str); if ($pl>$slen){ print "ERROR: $pl is greater than $slen"; } my %nu_hash=(); #why is this an empty hash? (is he storing patterns +in a hash?) my $sstr =""; #why is this an empty string? for(my $i=0;$slen>=$i+$pl; $i++) { $sstr=substr($str,$i,$pl); $nu_hash{$sstr}++; } return \%nu_hash; }
i know my question is quite lengthy, but bear with me :-),
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble understanding code, and shift() w.o args
by moritz (Cardinal) on Aug 04, 2011 at 15:16 UTC | |
|
Re: trouble understanding code, and shift() w.o args
by jwkrahn (Abbot) on Aug 04, 2011 at 17:49 UTC | |
|
Re: trouble understanding code, and shift() w.o args
by AR (Friar) on Aug 04, 2011 at 15:23 UTC | |
|
Re: trouble understanding code, and shift() w.o args
by GotToBTru (Prior) on Aug 04, 2011 at 15:41 UTC | |
by DanielM0412 (Acolyte) on Aug 04, 2011 at 15:55 UTC | |
by GotToBTru (Prior) on Aug 04, 2011 at 16:47 UTC |