What's the reason for redeclaring the $id variable in the final 'for' loop?
Habit, keeping things local to where they are used rather than global in scope.
I'm also wondering whether the length function works on a hash such as $seq{$id} in the same way it works on say something like $id?
to length either is just yet another string
| [reply] |
I'm also wondering whether the length function works on a hash such as $seq{$id} in the same way it works on say something like $id?
$seq{$id} is not a hash, but a value, and it's length can be determined, as with any string or number or byte sequence. In Perl speak, the word hash denotes the whole structure of an associative array holding key/value pairs. A hash is minced meat, and that's what's done to the key of a tuple: it is transformed via a hashing function into something that can be used as index into an associative array. So, a perl "hash" is an "unordered collection of scalar values indexed by their associated string key (perldata) which for lookup purposes is minced through a hashing function". For entries (key/value pairs) in such a collection (hash entry) the string key is often referred to as hash key and the value as hash value.
This may sound pedantic and as nitpicking (sorry about that), but people understand each other better if they agree on the meaning of terms.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
| [reply] [d/l] |