Thread Subroutine bei warning verlassen (5 answers)
Opened by Borsti26 at 2014-06-30 11:47

Gast wer
 2014-06-30 12:55
#176228 #176228
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
use strict;
use warnings;

print "Start\n";
event_start();
print "Should be visible even there is a warning\n";


sub event_start {
  my $ret=0;
  my $val='test';
  my $ok=eval { 
    local $SIG{__WARN__} = sub { 
      die( "\nWarning generated:\n", @_ ); 
    };
    
    $ret++ if($test==1) ;

    return 1;
  };
  unless($ok) {
    my $func_name=(caller(0))[3];
    print "format error in $func_name ($@)\n";
    return 0;
  }
  return $ret;
}

ungetestet
Last edited: 2014-06-30 13:33:24 +0200 (CEST)

View full thread Subroutine bei warning verlassen