<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
  <title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
I've made a brief attempt to understand this item, after stumbling
across it while looking up something else -- a typical short story of
my professional life, I guess! ;-)<br>
<br>
How is the <tt>Scalar::Util::dualvar</tt> subroutine implemented?&nbsp;
Yes, I've looked at the C source code in the <tt>ext/List/Util/Util.xs</tt>
file...&nbsp;
but as soon as I saw variables with the string "magic" embedded in the
name, I gave up.<br>
<br>
The closest real-life example seems to be Perl built-in errors, in
other words, using errno=2 as an example,<br>
<br>
<blockquote><tt>% perl -de 0</tt><br>
  <br>
  <tt>Loading DB routines from perl5db.pl version 1.19</tt><br>
  <tt>Editor support available.</tt><br>
  <br>
  <tt>Enter h or `h h' for help, or `man perldebug' for more help.</tt><br>
  <br>
  <tt>main::(-e:1):&nbsp;&nbsp; 0</tt><br>
  <tt>&nbsp; DB&lt;1&gt; $! = 2;</tt><br>
  <br>
  <tt>&nbsp; DB&lt;2&gt; print $!;</tt><br>
  <tt>No such file or directory</tt><br>
  <tt>&nbsp; DB&lt;3&gt; print $!+0;</tt><br>
  <tt>2<br>
&nbsp; DB&lt;4&gt; print 'No such file or directory' + 0<br>
0<br>
  </tt></blockquote>
<br>
As a database-oriented person, I'm wondering if there are any other
real-life examples for using this capability -- overloading a variable
with both string and numeric datatypes...<br>
<br>
Is there any situation where casting a scalar as "dualvar" would be
preferable to simply creating a hash, with numbers as keys and
corresponding strings as values?<br>
<br>
<pre class="moz-signature" cols="72">-- 
Mark Bole
<a class="moz-txt-link-freetext" href="http://www.bincomputing.com">http://www.bincomputing.com</a>
925-287-0366

</pre>
</body>
</html>