BEGIN { my $p_id_hash = { }; sub my_create { my ($w, $thing, $pparams) = @_; my $id = $w->$thing(@$pparams); my $pinfo = caller_info(); $p_id_hash->{$id} = [ $thing, @$pinfo ]; return $id; } sub caller_info { my $ln = (caller(1))[2]; my $sub = (caller(2))[3]; return [ $ln, $sub ]; } sub my_delete { my ($w, $id) = @_; my $pinfo = $p_id_hash->{$id} || 0; if (!$pinfo) { error_msg("Attempt to delete ID '$id' twice!"); } else { $w->delete($id); delete $p_id_hash->{$id}; return $id; } } sub show_id_hash { my @keys = sort keys %$p_id_hash; my $total = @keys; print "=" x 79, "\n"; for (my $i = 0; $i < $total; $i++) { my $key = $keys[$i]; my $pval = $p_id_hash->{$key}; my ($thing, $ln, $sub) = @$pval; printf "%3d. %16.16s -- %s[%4d]\n", $i+1, $thing, $sub, $ln; } print "Total keys = $total\n"; print "=" x 79, "\n"; } }