good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Filehandle woesby count0 (Friar) |
on Dec 11, 2001 at 00:55 UTC ( [id://130773]=perlquestion: print w/replies, xml ) | Need Help?? |
count0 has asked for the wisdom of the Perl Monks concerning the following question:
I have the misfortune of being in the position to maintain some rather poorly written Perl code.
In one package, a filehandle is created using Socket::socket(). This filehandle (called SOCK) is passed to a subroutine in another package like so: Otherpackage::foo(SOCK) foo() takes that argument as a scalar: sub foo { my $fh = shift; #.... } and goes even further to make a copy of it(?) like so: my $txt = <$fh> This just seems inherently wrong to me. But it worked just fine when run with perl 5.004_01. When used with a newer version it doesn't. It seems to me that this may have just happened to run ok by chance. But before I go about haphazardly rewriting these two modules to use typeglobs or object filehandles, I'd like to know if perhaps there's more to this bit than I'm recognizing... especially in regards to the $txt = <$fh> part.
Back to
Seekers of Perl Wisdom
|
|