<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>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.</div><div><br></div><div>Thanks for the info and the link!</div><div><br></div><div><br>On Mar 27, 2014, at 10:26 PM, Benjamin Holzman <<a href="mailto:bholzman@gmail.com">bholzman@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>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 <a href="http://cpansearch.perl.org/src/RURBAN/illguts-0.36/index.html#svpviv">http://cpansearch.perl.org/src/RURBAN/illguts-0.36/index.html#svpviv</a></div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Mar 27, 2014 at 9:46 PM, Patrick Cronin <span dir="ltr"><<a href="mailto:oshihuna@gmail.com" target="_blank">oshihuna@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I manage a CentOS 5.10 server running perl 5.8.8. For <REASONS>, I can't upgrade it.</div>
<div><br></div><div>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.</div>
<div><br></div><div>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?</div>
<div><br></div><div>I'm trying variations of the following:</div><div><br></div><div>my $int = 2;</div><div>my $string = "test";</div><div><br></div><div>my $typeglob = $int;</div><div>*typeglob{SCALAR} = ${ *string };</div>
<div><br></div><div>print ($typeglob + 2) . "\n";</div><div>print $typeglob . " YES!\n";</div><div><br></div><div>It just feels gross, and it's not working.</div><div><br></div><div>Does anyone have the magic?</div>
<div><br><hr style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:-webkit-auto;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:Helvetica;word-spacing:0px">
<table style="font-family:Helvetica;letter-spacing:normal;text-indent:0px;text-transform:none;word-spacing:0px"><tbody><tr><td style="vertical-align:top;width:70px"><img width="70" height="69" src="http://cronin.dyndns.org/avatar.jpg" align="left" hspace="9" alt="Patrick's Avatar"></td>
<td><span style="font-family:Calibri"><u></u><b><span style="color:rgb(31,73,125);font-size:12pt">Patrick Cronin</span></b><span> </span><u></u><br><span style="color:rgb(89,89,89);font-size:10pt"><u></u>Computer Lover<u></u><br>
<u></u>Mobile: <a href="tel:%2B1%20518%20336%205133" value="+15183365133" target="_blank">+1 518 336 5133</a><u></u><br><u></u>Email:<span> </span><a href="mailto:oshihuna@gmail.com" target="_blank">oshihuna@gmail.com</a><br>
Skype: patrickcronin12061<u></u><span> </span></span></span><span style="font-size:8pt;color:green"><br><br><span style="font-family:webdings">P</span><span> </span><span style="font-family:arial">Please consider the environment before printing this e-mail / attachments</span><span> </span>  </span><span> </span></td>
</tr></tbody></table>
</div>
<br></div><br>_______________________________________________<br>
Albany-pm mailing list<br>
<a href="mailto:Albany-pm@pm.org">Albany-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/albany-pm" target="_blank">http://mail.pm.org/mailman/listinfo/albany-pm</a><br></blockquote></div><br></div>
</div></blockquote></body></html>