Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Sunday, March 31, 2013

defined hash

The reason that defined(%hash) is deprecated is apparently that it returns some internal memory-allocation property of the hash, and that this property is true when the hash is undefined in the Perl sense of things (eg having been set to undef).

Just %h is a perfectly good test and returns false if %h has been set to undef or (undef) (which seems to be the same thing).

Furthermore, you can't undefine a hash or array by assigning undef to them:

  • %h = undef results in %h having one key, '', mapped to undef (and also gives an 'odd number of hash elements' warning)
  • @a = undef results in @a having one element, undef
The two correct ways to undefine an array or hash are:
  • undef %h
  • %h = ()

Followers

Blog Archive