If Inline::C is not available, that uses the pure-perl implementation of foo() and outputs:use strict; use warnings; eval { require Inline; Inline->import (C => Config => BUILD_NOISY => 1); require Inline; Inline->import (C =><<' EOC'); int foo() { warn("Using Inline\n"); return 42; } EOC }; # If Inline is unavailable, foo() simply calls # the sub bar() pure perl implementation. if($@) { *foo =\&bar; } sub bar { warn("Using Pure Perl Implementation\n"); return 42; } my $x = foo(); print "$x\n";
Otherwise, it uses the the Inline::C implementation of foo() and outputs:Using Pure Perl Implementation 42
NOTE: Running that script with Inline support will also output the C compilation report - but only for the *first* running, of course.Using Inline 42
In reply to Re: Best way to implement Inline::C/Pure Perl function in a module?
by syphilis
in thread Best way to implement Inline::C/Pure Perl function in a module?
by uG
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |