Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eval Question and Blocks

Status
Not open for further replies.

timgerr

IS-IT--Management
Joined
Jan 22, 2004
Messages
364
Location
US
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];
};
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

-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!

 
eval { code }; print $@; next if $@;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top