Hi,
Can someone please explain what a BEGIN block does?  I see from my books
and online documentation that BEGIN blocks are run at compile time and
are run only once, but I'm not sure how that's different from any other
perl code that's not in a loop.  Also, in my test script (below) the
block would only work if it was before the uninitialized variable, which
seems odd.  Thanks,
Miles

#! /usr/bin/perl -w
# this is a script to test error handling

use strict;
use diagnostics;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser set_message);

BEGIN {
sub handle_errors {
 my $msg = shift;
 print "<h1>Oh gosh</h1>";
 print "<p>\nGot an error: $msg";
}
set_message(\&handle_errors);
}

#the error to be handled
@spnee!;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to