From: "Chris Benco" <[EMAIL PROTECTED]>
> Having problems when this script hits a hash that is undefined. This
> happens when it does a look-up for a field in a notes database and it
> is blank. Read on Perl Monks to give it the ability to use another
> value when this happens to keep the script form halting. The example
> they give was something like this.
>
> my $From = $Document->GetFirstItem('From')->{Text} or ();
Do it like this:
my $From;
eval {
$From = $Document->GetFirstItem('From')->{Text};
};
if ($@) {
$From = ''; # or whatever default you want
}
The eval{} will make sure the error doesn't kill your script, the $@
contains the error message if there was an error. In such case you
can set the $From to whatever default you like.
You may even do this:
my $From = ''; # the default
eval {
$From = $Document->GetFirstItem('From')->{Text};
};
HTH, Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz
==========
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]