Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

(tye)Re: How to make bi-modal variables like $! ?

by tye (Sage)
on Jun 28, 2001 at 20:33 UTC ( #92359=note: print w/replies, xml ) Need Help??


in reply to How to make bi-modal variables like $! ?

See SetDualVar, which includes XS code (C code) that sets the string/number value of a scalar without invalidating the other.

        - tye (but my friends call me "Tye")
  • Comment on (tye)Re: How to make bi-modal variables like $! ?

Replies are listed 'Best First'.
Re: (tye)Re: How to make bi-modal variables like $! ?
by bikeNomad (Priest) on Jun 28, 2001 at 20:45 UTC
    Cool! Re-writing the guts of SetDualVar using Inline, it looks like:

    #!/usr/bin/perl -w # Solution by Kenneth Albanowski <kjahds@kjahds.com> # from the module SetDualVar-1.0.tar.gz # re-written using Inline. 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* variable, SV* string, SV* numeric) { SvPV(string, PL_na); if(!SvPOKp(string) || (!SvNOKp(numeric) && !SvIOKp(numeric)) ) { croak("Usage: set_both variable,string,numeric"); } sv_setsv(variable,string); if(SvNOKp(numeric)) { sv_setnv(variable,SvNV(numeric)); } else { sv_setiv(variable,SvIV(numeric)); } SvPOK_on(variable); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://92359]
help
Chatterbox?
[Discipulus]: uh no choroba.. i do not practice much with online putyour image sites:can you suggest one (that possibly remove the pic after few days)?
[choroba]: Corion a bug report?
[choroba]: I have no idea :-( I used to post to photobucket.com, but they don't seem to feature "private" pictures in the free version now
[Discipulus]: dazz i'm not an experts but i think it would be possible
[Corion]: dazz: I think Image::Magick can "read" from an in-memory filehandle
[Corion]: choroba: No, some general admin discussion of how to handle (company) user accounts
[Discipulus]: might be it is necessary to pass the pic data like MIME::Base64:: encode( data..
[Discipulus]: if you have a jpeg data: or as wise Corion said IM ca n read directly your handle

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-03-27 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (317 votes). Check out past polls.