Ah Patrick, I've got bad news for you...<div><br></div><div>You're mixing up typeglobs and scalars. A typeglob is essentially a symbol table entry that holds everything with different sidles.  So the *foo typeglob holds $foo, @foo, &foo, %foo, etc, etc.</div>
<div><br></div><div>A scalar is little C struct[1] that holds a integer value, a floating point value, a pointer to a string, etc etc and a set of flags indicating which of these are valid or not. Whenever Perl needs a different kind of value - say the sting form of some scalar computed by a numerical calculation - it converts the value from one of the other forms and stores it back in the scalar and marks the flags to indicate that right now both values are good and Perl doesn't need to do any conversion.</div>
<div><br></div><div>A dualvar is essentially a scalar where you can manually set the string part and numerical part of the scalar by hand to different values.</div><div><br></div><div>So, no we can't use typeglobs because typeglobs only have one entry for a scalar in them, not a separate scalar for numerical and string values.</div>
<div><br></div><div>To make matters worse, there's no way as far as I know to access the various parts of a scalar from Perl space without using some XS code.</div><div><br></div><div>Possible further solutions:</div>
<div><br></div><div>- ask for help with Net::SSH</div><div>- shell out to the system ssh binary, possibly using an Expect command if you need to</div><div>- install a custom Perl just for this task. perlbrew is your friend here.</div>
<div><br></div><div>Mark<br><br>[1] technically a set of structs depending on how it's being used, but that's not important right now.</div><div><span></span><br>On Thursday, March 27, 2014, Patrick Cronin <<a href="mailto:oshihuna@gmail.com">oshihuna@gmail.com</a>> 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: +1 518 336 5133<u></u><br><u></u>Email:<span> </span><a href="javascript:_e(%7B%7D,'cvml','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></blockquote></div>