This program:

#!/usr/bin/perl use Spreadsheet::ParseXLSX; `echo "" >/tmp/invalid.xlsx`; eval { Spreadsheet::ParseXLSX->new->parse("/tmp/invalid.xlsx") };

prints:

format error: file is too short at /usr/share/perl5/Archive/Zip/Archive.pm line 1031. Archive::Zip::Archive::_findEndOfCentralDirectory(Archive::Zip::Ar +chive=HASH(0x56216520bf48), IO::File=GLOB(0x562165214f30)) called at +/usr/share/perl5/Archive/Zip/Archive.pm line 761 Archive::Zip::Archive::readFromFileHandle(Archive::Zip::Archive=HA +SH(0x56216520bf48), IO::File=GLOB(0x562165214f30), "/tmp/invalid.xlsx +") called at /usr/share/perl5/Archive/Zip/Archive.pm line 729 Archive::Zip::Archive::read(Archive::Zip::Archive=HASH(0x56216520b +f48), "/tmp/invalid.xlsx") called at /usr/share/perl5/Spreadsheet/Par +seXLSX.pm line 63 Spreadsheet::ParseXLSX::parse(Spreadsheet::ParseXLSX=HASH(0x562165 +1e94d8), "/tmp/invalid.xlsx") called at ./quiete_xlsx line 8 eval {...} called at ./quiete_xlsx line 7

How can I grab all erorrs to some variable without polluting stderr?


In reply to Make Spreadsheet::ParseXLSX be quiet about errors by leszekdubiel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.