#!/usr/bin/perl use strict; use warnings; use Inline C => <<'END_C'; SV* concat(SV *a, SV *b) { SV *c; if (SvOK(a)) c = newSVsv(a); else c = newSVpvn("", 0); if (SvOK(b)) sv_catsv(c, b); return c; } void append(SV *a, SV *b) { if (!SvOK(a)) sv_setpvn(a, "", 0); if (SvOK(b)) sv_catsv(a, b); } END_C my @pairs = ( [ 'bill', undef ], [ 'bill', 'fred' ], [ undef, 'fred' ], [ 1, undef ], [ 1, 1 ], ); test($_) for @pairs; sub test { my $pair = shift; my $c = concat(@$pair); print "$c\n"; append(@$pair); print "$pair->[0]\n"; }