#!/usr/bin/perl use warnings; use Tk; use Inline C; use strict; $| = 1; #this ones returns ints, not floats my $mw = tkinit; $mw->Button( -text => 'Get Array from C', -command => sub { &get_data(); })->pack(); $mw->Button( -text => 'Quit', -command => sub { exit; })->pack(); MainLoop; ###################################### sub get_data { my $freq_adj = .1; my $vol = .5; my @raw = gen($freq_adj, $vol); print "@raw\n\n"; } __END__ __C__ #include #include /* function must return void for Inline to use the stack See the Inline_C cookbook */ void gen(float freq_inc , float vol) { /* two numbers to work with */ float result, rad; rad = .1; Inline_Stack_Vars; Inline_Stack_Reset; while ( rad < 6.3 ) { rad = rad + freq_inc; result = vol * 32768 * sin(rad); /* printf("%6.6f\n",result); */ Inline_Stack_Push(sv_2mortal(newSViv(result))); } Inline_Stack_Done; }