<html>
<body>
This seems to work too:-<br><br>
<tt>#!/usr/bin/perl<br><br>
use strict;<br><br>
my $num = 3;<br><br>
print &quot;$num\n&quot;;<br><br>
double($num);<br><br>
print &quot;$num\n&quot;;&nbsp; # 6 expected<br><br>
#------------------------#<br><br>
sub double<br>
{<br>
&nbsp;&nbsp;&nbsp; $_[0] *= 2;<br>
}<br><br>
<br><br>
</tt>At 2004/01/09 10:04 AM, Sean Carte wrote:<br>
<blockquote type=cite class=cite cite>On Fri, 2004-01-09 at 08:58, Spike
wrote:<br>
&gt; Hi All<br>
&gt; <br>
&gt; First query of the year!<br><br>
First answer of the year!<br><br>
&gt; <br>
&gt; If I have a function (sub routine) like :<br>
&gt; <br>
&gt; sub double {<br>
&gt; my $num = shift;<br>
&gt; return $num * 2;<br>
&gt; }<br>
&gt; <br>
&gt; I could say:<br>
&gt; <br>
&gt; $value = 3;<br>
&gt; $value = double($value);<br>
&gt; print &quot;$value\n&quot;;&nbsp; #&nbsp;&nbsp; 6 expected<br>
&gt; <br>
&gt; My question is how could I write that function so that it 
works<br>
&gt; directly on the variable that is passed to it in the same way
that<br>
&gt; functions like chomp do?<br>
&gt; <br>
&gt; $value = 3;<br>
&gt; double($value);<br>
&gt; print &quot;$value\n&quot;;&nbsp; #&nbsp;&nbsp; 6 expected<br>
&gt; <br><br>
Use references:<br><br>
$value = 3;<br>
double(\$value); # pass a reference to $value<br>
print &quot;$value\n&quot;;&nbsp; #&nbsp;&nbsp; 6 expected<br><br>
sub double {<br>
&nbsp; my $ref = shift;<br>
&nbsp; $value = $$ref; # dereference $ref<br>
&nbsp; $value *= 2;<br>
}<br><br>
-- <br>
Sean Carte &lt;scarte@pan.uzulu.ac.za&gt;<br>
University of Zululand<br><br>
<br>
______________________________________<br>
Inflex - installed on mailserver for domain @pan.uzulu.ac.za<br>
Queries to: postmaster@pan.uzulu.ac.za </blockquote>
<x-sigsep><p></x-sigsep>
<tt><br>
<font face="Courier New, Courier" size=2>Spike Hodge<br><br>
</font></tt><font face="Courier New, Courier">UNIX Programmer<br>
M-Web Technology<br>
021 596 8496<br>
083 294 9593<br>
Fax 0866721733<br><br>
<br>
</font>Click here and make M-Web your homepage<br>
<a href="http://homepage.mweb.co.za/" eudora="autourl">http://homepage.mweb.co.za</a>
</body>
</html>