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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Explain me please the following command ..

Status
Not open for further replies.

shlomyb

Programmer
Nov 14, 2006
32
IL
Hi

Here is the code :
eval {$a = $parser->parsefile("$OLD_CONF_DIR$file");};
& {&LOG("ERROR","Erorr ...");print $@; exit(1); } if $@;


My question is not related to the eval command but to the "&" after it.... what does it mean ?
 
It seems to be calling an anonymous subroutine. It would be equivalent to this:

Code:
sub on_error {
   &LOG ("ERROR, "Error...");
   print $@;
   exit(1);
}
&on_error if $@;

-------------
Kirsle.net | Kirsle's Programs and Projects
 
also same as:

Code:
eval {$a = $parser->parsefile("$OLD_CONF_DIR$file");};
if ($@) {
   &LOG("ERROR","Error: $@");
   print $@;
   exit(1);
}

- Kevin, perl coder unexceptional!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top