Leser: 17
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 29 30
#!/usr/bin/perl use strict; use warnings; my $e1 = Error->new; if($e1) { print "Error object: $e1"; } else { $e1->message; } unless(my $foo = bar()) { $foo->message; } sub bar { return Error->new; } package Error; use overload '""' => sub { '' }; sub new { return bless {}, shift; } sub message { print "Error message!\n"; } 1;