- my $internal_pkg = Xchat::Embed::file2pkg($file);
- no warnings 'redefine';
- local *Xchat::Embed::find_pkg = sub { $internal_pkg, $caller };
- local *HexChat::Embed::find_pkg = sub { $internal_pkg, $caller };
- Xchat::register(@opts{qw<name version banner>}, sub {
- $ph->flush;
- if (*$ph->{atexit_id}) {
- my @callbacks = sort { *$ph->{atexit}{$b} <=> *$ph->{atexit}{$a} }
- keys %{*$ph->{atexit}};
- $_->($ph) for @callbacks;
- }
- undef $ph;
- });
+ called_from_script {
+ Xchat::register(@opts{qw<name version banner>}, sub {
+ $ph->flush;
+ if (*$ph->{atexit_id}) {
+ my @callbacks = sort { *$ph->{atexit}{$b} <=> *$ph->{atexit}{$a} }
+ keys %{*$ph->{atexit}};
+ $_->($ph) for @callbacks;
+ }
+ undef $ph;
+ })
+ };