1 2 3 4 5 6 7 8 9 10
use Win32::SqlServer; eval { die('Fehlermeldung'); my $connection = new Win32::SqlServer(); } or do { print $@; }; #Ausgabe: Fehlermeldung at ...
1 2 3 4 5 6 7 8 9 10
use Win32::SqlServer; eval { my $connection = new Win32::SqlServer(); die('test_irgendwas'); } or do { print "_" . $@ . "_"; }; #keine Ausgabe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
sub DESTROY { my ($self) = @_; delete $my_objects{$self}; # We run the destruction in eval, as Perl sometimes produces an error # message "Can't call method "FETCH" on an undefined value" when the # destructor is called a second time. eval('xs_DESTROY($self)'); unless ($@) { # We must clear internaldata, since Perl calls the destructor twice, but # on the second occasion, the XS code has already deallocated internaldata. # The XS code has problem with setting values in stored hashes, why we do # it. This assignment cannot be in eval, since the STORE method only # permits DESTROY to change internaldata. $$self{'internaldata'} = 0; } }
1 2 3 4 5 6 7 8 9 10 11 12
use Win32::SqlServer; do { my $connection; eval { $connection = new Win32::SqlServer(); die 'aargh!' } if ($@) { print "Error: $@"; }; };