use strict; use warnings; my $point = pack 'f2', 1.2, 2.3; func(\$point); func(undef); # pass in 'NULL pointer' use Inline C => <<'C_END'; typedef struct { float x, y; } Point; void func(SV *buf) { SV *point_ref = SvRV(buf); if (!point_ref) { printf("got a null pointer\n"); } else { /* dereference */ Point *point = (Point *)SvPV_nolen(point_ref); printf("x=%.2f, y=%.2f\n", point->x, point->y); } } C_END