in reply to Making a variable available to another package in a call back

The variable is not lost. Seems your callback just not called.

Update: Your callback is not called in the code you given. Anyway, if you specify package for $test it is not lost.

sub hook { my ($filename, $buffer, $bytes_read, $data) = @_; print $::test; }