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); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to make bi-modal variables like $! ?
by japhy (Canon) on Jun 28, 2001 at 20:14 UTC | |
(tye)Re: How to make bi-modal variables like $! ?
by tye (Sage) on Jun 28, 2001 at 20:33 UTC | |
by bikeNomad (Priest) on Jun 28, 2001 at 20:45 UTC | |
Re: How to make bi-modal variables like $! ?
by cLive ;-) (Prior) on Jun 29, 2001 at 01:41 UTC | |
Re: How to make bi-modal variables like $! ?(boo)
by boo_radley (Parson) on Jun 28, 2001 at 20:04 UTC | |
by bikeNomad (Priest) on Jun 28, 2001 at 20:08 UTC | |
Re: How to make bi-modal variables like $! ?
by bart (Canon) on Apr 22, 2005 at 07:27 UTC | |
Re: How to make bi-modal variables like $! ?
by bwana147 (Pilgrim) on Jun 28, 2001 at 20:03 UTC |
Back to
Seekers of Perl Wisdom