Remember a variable must be declared with my (not local) to retain its value in a closure.
Technique for handlers (or 'how to supply a reference to an instance method'):
set_callback( \&method )
will not work inside an object because at the time the callback is run, Perl doesn't know what object the method belongs to. Instead I use
$copyinst = $inst;
set_callback( sub { &method($copyinst, @_); } )
where $inst is the instance variable (I'm never sure whether the copy is necessary or not). method will now be called properly, and like all methods will have the instance as the first argument, followed by whatever arguments the caller supplies.
There's supposed to be another way round this but I've never been able to make that work.
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 )