[albany-pm] Typeglobs help!

Packy Anderson packy at dardan.com
Thu Mar 27 21:25:04 PDT 2014


Another thought: you say for <REASONS> you can't upgrade "it".  Which item
does "it" refer to, the "CentOS 5.10" or the "perl 5.8.8"?

Would it be possible to use perlbrew <http://perlbrew.pl/> to install a
parallel, newer version of perl that, perhaps, you CAN install the XS
version of Scalar::Util into?  You wouldn't be upgrading either the OS or
the system perl: you'd be installing a parallel perl installation which has
it's own library of modules.  It's what I do when I'm on a system and need
a better perl than what's in /usr/bin/perl; that way, I don't have to worry
about screwing up anything that depends on the ancient version of perl that
shipped with the OS.

Just a thought...

-packy


On Thu, Mar 27, 2014 at 11:26 PM, Patrick Cronin <oshihuna at gmail.com> wrote:

> I have the book Mastering Perl, and a few months ago I thought I was
> pretty good. Now I just learned that Mastering Perl is only half of what
> Perl is all about.
>
> Thanks for the info and the link!
>
>
> On Mar 27, 2014, at 10:26 PM, Benjamin Holzman <bholzman at gmail.com> wrote:
>
>
> Don't think there is a pure perl way to do a dualvar. It's got nothing to
> do with typeglobs, dualvars work by abusing the IVX slot of a PVIV scalar.
> See http://cpansearch.perl.org/src/RURBAN/illguts-0.36/index.html#svpviv
>
>
> On Thu, Mar 27, 2014 at 9:46 PM, Patrick Cronin <oshihuna at gmail.com>wrote:
>
>> 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?
>>
>> ------------------------------
>> [image: Patrick's Avatar] *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
>>
>>
>> _______________________________________________
>> Albany-pm mailing list
>> Albany-pm at pm.org
>> http://mail.pm.org/mailman/listinfo/albany-pm
>>
>
>
> _______________________________________________
> Albany-pm mailing list
> Albany-pm at pm.org
> http://mail.pm.org/mailman/listinfo/albany-pm
>



-- 
Packy Anderson

Email:  packy at dardan.com
GVoice: (646) 833-8832
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/albany-pm/attachments/20140328/c0e34bd6/attachment-0001.html>


More information about the Albany-pm mailing list