Skip to content

Instantly share code, notes, and snippets.

@berekuk
Created May 17, 2012 19:27
Show Gist options
  • Select an option

  • Save berekuk/2721102 to your computer and use it in GitHub Desktop.

Select an option

Save berekuk/2721102 to your computer and use it in GitHub Desktop.
require fails when called from exception()
$ ./test.t
exception script.pl did not return a true value at ./test.t line 9.
$ perl --version
This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi
#!/usr/bin/env perl
package X;
use strict;
use warnings;
sub f {
return 1;
}
return f(); # if I replace this with direct 'return 1', error goes away
#!/usr/bin/perl
use strict;
use warnings;
use Test::Fatal;
# if I replace exception() with my $f = sub { ... }, error goes away
my $e = exception(sub {
require 'script.pl';
# 1; # if I uncomment this line, error goes away
});
if (defined $e) {
warn "exception $e";
}
else {
warn "ok";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment