# Untested. Note also that this code will not handle special # cases as STDERR being closed, tied or attached to a file # descriptor different than 2. use autodie; use File::Temp qw(tempfile); open my $olderr, '>&STDERR'; # save STDERR my $fh = tempfile(); open STDERR, '>&', $fh; my $entry = Text::BibTeX::Entry->new($bib_entry); open STDERR, '>&', $olderr; # flush and reset STDERR seek($fh, 0, 0); my $err = do { local $/; <$fh> }; close $fh;