perlquestion
r.joseph
Really quick question. When passing around filehandles between subs, what is the difference between:
<code>
sub one (*) { my $fh = shift; print $fh "$fh (glob)"; }
open (OUTER,"+>out.txt") or die "$!\n\n";
one (\*OUTER);
</code>
and a very <i>slight</i> change:
<code>
sub one (*) { my $fh = shift; print $fh "$fh (glob)"; }
open (OUTER,"+>out.txt") or die "$!\n\n";
one (*OUTER);
</code>
As you can see, in the first example it seems that I have passed a glob reference to the sub, while in the second example I have simply passed the glob. Both work exactly the same, yet I have seen both - what is the difference (is one advantageous over the other)?
<br><br>
Also, what is the reason that if I protoype one() like this:
<code>
sub one(\*) { ... }
</code> it <i>doesn't</i> work, but
<code>
sub one(*) { ... }
</code> does? I would think that using <code>\*</code> would just require a glob reference - where am I wrong?<br><br>
Thanks for the help - these glob things are very new to me!
<br><br>
<font color="#222255">r.</font>
<font color="#333366">j</font>
<font color="#444477">o</font>
<font color="#555588">s</font>
<font color="#666699">e</font>
<font color="#7777aa">p</font>
<font color="#8888bb">h</font><br>
<i>"Violence is a last resort of the incompetent"</i> - Salvor Hardin, <i>Foundation</i> by Issac Asimov