in reply to Re^2: Comparing 2 different-sized strings
in thread Comparing 2 different-sized strings
Can you just explain to me what the double dollar sign in front of rNee means?
It means dereference the reference.
Because genomic work often involves very large strings; and passing large strings into subroutines causes them to be copied:
sub something { my( $string ) = @_; ## $string is a copy of the argument } my $hugeString = ........; something( $hugeString );
Instead of passing the arguments directly, I pass references (kind of pointers) to them:
fuzzyMatch( \$hay, \$nee, 3 ); ## pass references to needle and haysta +ck
Within fuzzyMatch(), it receives references to the two strings:
sub fuzzyMatch { my( $rHay, $rNee, $misses ) = @_; ## the 'r's are to remind that +these are references
So to get to the actual strings, I use a second $
my $lNee = length $$rNee; ## read as: $lenghtNeedle = length of t +he data $, referenced by $rNee
So, $$rNee is shorthand for ${ $rNee }; if that clarifies things for you?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Comparing 2 different-sized strings
by AdrianJ217 (Novice) on Aug 09, 2013 at 11:46 UTC | |
by BrowserUk (Patriarch) on Aug 09, 2013 at 12:00 UTC | |
|
Re^4: Comparing 2 different-sized strings
by AdrianJ217 (Novice) on Aug 10, 2013 at 19:27 UTC | |
by BrowserUk (Patriarch) on Aug 10, 2013 at 21:27 UTC | |
by AdrianJ217 (Novice) on Aug 11, 2013 at 08:43 UTC | |
by BrowserUk (Patriarch) on Aug 11, 2013 at 09:12 UTC | |
by AdrianJ217 (Novice) on Aug 12, 2013 at 14:08 UTC | |
|