[albany-pm] Typeglobs help!

Patrick Cronin oshihuna at gmail.com
Thu Mar 27 18:46:19 PDT 2014


I manage a CentOS 5.10 server running perl 5.8.8. For <REASONS>, I can't upgrade it.

For some reason, I can't install the XS version of Scalar::Util, and so I'm stuck using the PP version. Net::OpenSSH relies on Scalar::Util's dualvar function (which is only available in the XS version of Scalar::Util) to create a single scalar holding both an integer and string value. When the scalar is used in a numeric context, the integer value comes out, and when the scalar is used in a string context, the string value comes out. I'm trying to write a quick and dirty PP version of dualvar so I can move on with my life.

I seem to remember seeing this being done, but no amount of googling is getting me there. I've looked up typeglobs and the *foo{THING} construct, but while THING can be SCALAR, it can't be NUMBER or STRING. Does anyone know the magic to make this happen?

I'm trying variations of the following:

my $int = 2;
my $string = "test";

my $typeglob = $int;
*typeglob{SCALAR} = ${ *string };

print ($typeglob + 2) . "\n";
print $typeglob . " YES!\n";

It just feels gross, and it's not working.

Does anyone have the magic?

	Patrick Cronin 
Computer Lover
Mobile: +1 518 336 5133
Email: oshihuna at gmail.com
Skype: patrickcronin12061 

P Please consider the environment before printing this e-mail / attachments 	 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/albany-pm/attachments/20140327/38a87ee4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.pm.org/pipermail/albany-pm/attachments/20140327/38a87ee4/attachment.bin>


More information about the Albany-pm mailing list