i have tried for hours now, and i am very upset, cause this should be super simple. File::Fetch::WARN, as I have read, when set to 0 will stop things from being carp'd (which outputs to STDOUT, no?). but, my code emits an error message when $PARAMS{url} does not exist when i need it to just shutup and let me handle the error. so i do this in my code:
use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use File::Copy; use File::Path qw(remove_tree rmtree); use File::Fetch; $File::Fetch::WARN = 0; use Fcntl; use URI::Escape; use English; my $ff = 0; eval { $ff = File::Fetch->new(uri => $PARAMS{url}); }; if (not $ff) { if ($DEBUG_OP_ADD_COVER_PHOTO) { $output .= "failed to retrieve image: " . $ff->error . "<br>\n"; } else { print error_redir(redirrer($OP_QUERY, $OP_FILE_MANAGER, $FOLDER_QU +ERY, $FOLDER), "Failed to Retrieve Image: " . $ff->error); exit 1; } }
the eval was added in as a suggestion to suppress the warning, but that doesn't work. $File::Fetch::WARN = 0 has no affect!

the fetching process emits a completely different error message, and it's printed (i presume to STDOUT) before i get to print anything to STDOUT! which causes "internal server error", and i can't get the thing to stop printing that damn junk out, it 'breaks' things!

Note: whilst $DEBUG_OP_ADD_COVER_PHOTO = 1, the error message emitted is: could not retrieve file: Command failed:. Nowhere in my code have I asked for that to be printed out.

Edit: Added "use" statements which may affect your answer. the code in this post is only a very small part of a much larger program.

I was pondering why the ball was getting bigger, and then...it hit me!


In reply to $File::Fetch::WARN = 0; not working? by jamroll

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.