Perl eval

From Teknologisk videncenter
Revision as of 09:54, 22 March 2009 by Heth (talk | contribs)
Jump to: navigation, search

Perl eval can be used as try and catch exception handling.

eval
{
    # try
};
if($@)
{
    # catch
}

Throwing an exception

eval
{
    # try
    die "Exception text to be catched";
};
if($@)
{
    # catch
}