http://qs321.pair.com?node_id=1150856

k0shinus has asked for the wisdom of the Perl Monks concerning the following question:

Thanks for all! It's working now, i just needed to replacing __END__ to __DATA__.

I need to write simple script, which calling functions from two modules (one of it contains perl code and another contains c code), measuares the time of each and if they calculation results are equals printing time differences of calulation. Problem is that when i include module with c code and run main script perl says: "readline() on unopened filehandle DATA at C:/other_perl/Strawberry/perl/site/lib/Inline.pm line 360. Use of uninitialized value $data in substitution (s///) at C:/other_perl/Strawberry/perl/site/lib/In line.pm line 360. Use of uninitialized value $data in split at C:/other_perl/Strawberry/perl/site/lib/Inline.pm line 3 61. No source code in DATA section for Inline 'C' section. at optest.pl line 0. INIT failed--call queue aborted. One or more DATA sections were not processed by Inline." Here is the main script:

use Time::HiRes qw(gettimeofday tv_interval); use Test::More; use perl_calc; use c_calc; $start_time_c = [ gettimeofday ]; $c_calc = c_calc::calc_pi(); $end_time_c = [ gettimeofday ]; $elapsed_c = tv_interval($start_time,$end_time); $start_time_perl = [ gettimeofday ]; $perl_calc = perl_calc::calc_pi(); $end_time_perl = [ gettimeofday ]; $elapsed_perl = tv_interval($start_time,$end_time); $differences = abs($elapsed_perl - $elapsed_c); if(ok($c_calc == $perl_calc, "Pi number calc")) { print "C computation time = $elapsed_c\n"; print "Perl computation time = $elapsed_perl\n"; print "Differences = $differences\n"; } done_testing;

Here is module with c code:

package c_calc; use Inline 'C'; 1; __END__ __C__ double my_abs(double num) { return (num > 0)? num : -num; } double calc_pi() { double real_pi = 3.14159265358979; double my_pi = 0; double step_sign = 1; unsigned long long i = 1; while(my_abs(real_pi - my_pi) > 0.00000001) { my_pi += 4.0/i * step_sign; step_sign *= -1; i += 2; } return my_pi; }

I read Inline::C-Cookbook, but i didn't find an answer there. So what i do wrong?