Using eval to test whether a function is implemented. : eval « System Functions « Perl






Using eval to test whether a function is implemented.

     
#!/usr/local/bin/perl 

open (MYFILE, "file1") || die ("Can't open file1"); 
eval ("\$start = tell(MYFILE);"); 
if ($@ eq "") { 
    print ("The tell function is defined.\n"); 
} else { 
    print ("The tell function is not defined!\n"); 
} 

   
    
    
    
    
  








Related examples in the same category

1.Using eval to evaluate an expression
2.The eval command executes a snippet of Perl code
3.Behavior of eval.