r.joseph has asked for the wisdom of the Perl Monks concerning the following question:
Really quick question. When passing around filehandles between subs, what is the difference between:
Also, what is the reason that if I protoype one() like this:
Thanks for the help - these glob things are very new to me!
r. j o s e p h
"Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov
and a very slight change:sub one (*) { my $fh = shift; print $fh "$fh (glob)"; } open (OUTER,"+>out.txt") or die "$!\n\n"; one (\*OUTER);
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)?sub one (*) { my $fh = shift; print $fh "$fh (glob)"; } open (OUTER,"+>out.txt") or die "$!\n\n"; one (*OUTER);
Also, what is the reason that if I protoype one() like this:
it doesn't work, butsub one(\*) { ... }
does? I would think that using \* would just require a glob reference - where am I wrong?sub one(*) { ... }
Thanks for the help - these glob things are very new to me!
r. j o s e p h
"Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Passing filehandles to subs.
by Chady (Priest) on May 05, 2001 at 12:25 UTC | |
Re (tilly) 1: Passing filehandles to subs.
by tilly (Archbishop) on May 05, 2001 at 16:03 UTC |
Back to
Seekers of Perl Wisdom