Dermot Paikkos wrote:
Hi,
Hello,
There are some functions in a C library that I would like to use and
I was wondering if it is possible to do so from perl.
Yes and it can be quite easy :)
search.cpan.org for Inline::C
From Damian Conway's most excellent (translated "go buy it now!!!")
"Perl Best Pratices" page 444: (apologize if I mistyped anything..)
use Inline C => q{
int
rounded(double arg) {
/* Round towards zero... */
if (arg > 0.0) { return floor(arg + 0.5); }
else if (arg < 0.0) { return ceil(arg - 0.5); }
else { return 0; }
}
};
use IO::Prompt;
while (my $num = prompt -num => 'Enter a number: ') {
print rounded($num), "\n";
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>