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

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

As you know, the error variable $! has both a numeric and a string value, depending on which context it's used in (that is, the numeric value may be 2, while the string value is "No such file or directory"). I'd like to make error variables like this (assigning to $! doesn't work right). How can I do it? I tried the following, which didn't work:

#!/usr/bin/perl -w use strict; use Inline 'C'; my $v; set_both($v, "I'm a string too!", 123); print $v+0, " $v\n"; __END__ __C__ void set_both(SV* var, char* str, int i) { sv_setpv(var, str); sv_setiv(var, i); }