On Wed, Dec 10, 2014 at 2:42 PM, Martin G. McCormick <
mar...@server1.shellworld.net> wrote:

> The line that causes a problem is:
>
>      $default_warn(@_);
>
> It looks like it should work.
>

Yeah, look at:
http://perldoc.perl.org/functions/warn.html

There is no warn sub at $SIG{__WARN__} so $default_warn is undef. If you
define a SIG{__WARN__}, it takes over for the normal handler, which is
still available via "warn()"

use warnings;

  my $ho;
  my $warning_occured = 0;
  #my $default_warn = $SIG{__WARN__};
  $SIG{__WARN__} = sub {
    $warning_occured = 1;
    warn("my: ", @_);
   };

print $ho;
  if ($warning_occured) {
      print "sent warning\n";# Code to run if a warning occured
  } else {
      print "didn't sent warning\n";# Code to run if a warning occured
      # Code to run if no warning occured
  }

I was thinking this would be a neat place to show the remaining reason for
using "&" to mark a function call - it sends the current "@_" to that
function, but I couldn't get it to work.

-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk

Reply via email to