+sub getwarning {
+ # captures the first warning produced by the given code string
+ my ($code, $line, $file) = @_;
+
+ local $SIG{__WARN__} = sub { die @_ };
+ # warnings module runs at BEGIN, so we need to use icky expression evals
+ eval qq(# line $line "$file"\n$code; return);
+ return $@;
+};
+