Wednesday, April 4, 2007

Perl pop quiz

What's wrong with this picture:


use strict;
use Error qw(:try);

my $result;
print "setting result to abc\n";
$result = "abc";
} catch Error with
print "caught an error\n";

my $a = $result;
print "a=$a\n";
print "result=$result\n";

Check out the output:

[root@devin rtest]# ./
setting result to abc

When Dan pointed out the error after looking at it for a few minutes, I wanted to cry.

The answer, for those who might be interested, will be in tomorrow's edition of "Why Devin Hates Perl"