The general form for block eval is:

#!/usr/bin/perl

use strict;
use warnings;

eval {
    die 'There was an error!!!' . "\n";
};

if ($@) {
    print $@;
}

print 'On the other side.' . "\n";

Robert



On Feb 19, 2007, at 4:13 PM, Gallagher, Tim F ((NE)) wrote:

I am working my butt off trying to get eval blocks working. When I run
a pert of perl code, if the code fails I dont want the script to
terminate.  Here is what I am talking about:
[CODE]
use Win32::Registry;

eval{
my ($node) = '\\\\ComputerName';
my ($hNode, $hKey, %values);
$HKEY_LOCAL_MACHINE->Connect ($node, $hNode) || warn "Cannot connect to
$node";
$hNode->Open ("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
$hKey)|| warn "Cannot open registry !";
$hKey->GetValues (\%values);
$hKey->Close ();
$hNode->Close ();

print $values{ProductName}[2] . "\n";
print $values{CSDVersion}[2];
};
[/code]

If this chunck of code does not work, or spits out an error then I want
to script to continue.  What am I doing wrong?

Thanks
-T

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to