[Pdx-pm] Some filehandle help needed
Kyle Dawkins
kyle at cepaso.com
Tue Aug 7 10:20:46 PDT 2007
Hi all
It's been a long time since I've had to diddle with filehandles with
any degree of complexity... I work exclusively in mod_perl land and
never need to deal with them. Something has come up where I need to
connect to a /dev/tty from mod_perl.
This works (feel free to tell me a better way to deal with the fh,
too... I need to use getc, so using IO::Handle seemed the best way to
do it... maybe that's my prob?):
...
my $_tty = _tty();
open my $_fout, "> /dev/$_tty";
my $fout = IO::Handle->new_from_fd($_fout, "w");
$fout->autoflush(1);
... do stuff with $fout ...
but this doesn't:
sub fout {
my $_tty = _tty();
open my $_fout, "> /dev/$_tty";
my $fout = IO::Handle->new_from_fd($_fout, "w");
$fout->autoflush(1);
return $fout;
}
...
my $fout = fout();
... do stuff with $fout ...
When I try to do stuff with $fout returned from a function, nothing
happens. The problem is, I really need to be able to move the code
that create the fh into a method in another package, hence my problem.
Perl 5.8.6 on OSX 10.4.9, Apache 1.3.33 with mod_perl 1.2.9
Any help appreciated!
Kyle Dawkins
kyle at cepaso.com
More information about the Pdx-pm-list
mailing list