in reply to Re: Picking out specific lengths from a set of hashes.
in thread Picking out specific lengths from a set of hashes.

Thank you. What's the reason for redeclaring the $id variable in the final 'for' loop? Edit: 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?
  • Comment on Re^2: Picking out specific lengths from a set of hashes.

Replies are listed 'Best First'.
Re^3: Picking out specific lengths from a set of hashes.
by huck (Prior) on May 11, 2017 at 18:56 UTC

    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

      Ahh, okay thanks.
Re^3: Picking out specific lengths from a set of hashes.
by shmem (Chancellor) on May 12, 2017 at 17:57 UTC
    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'