Closed p5pRT closed 20 years ago
my $file=new IO::File; ... correct open of file ... $file->ioctl(someReadOP\,$value);
does not work\, while ioctl($file\,someReadOp\,$value) does.
This is ioctl in IO::Handle.pm
560: sub ioctl { 561: @_ == 3 || croak 'usage: $io->ioctl( OP\, VALUE );'; 562: my ($io\, $op\, $val) = @_; 563: my $r = ioctl($io\, $op\, $val); 564: defined $r && $r eq "0 but true" ? 0 : $r; 565: }
The $val passed to ioctl in line 563 is a local variable because of the declaration in line 562. So any ioctl which reads a value will fill in $val instead of the parameter passed to $file->ioctl.
To fix this\, line 563 has to be changed into:
my $r = ioctl($io\, $op\, $_[2]);
This works (tested) because $_[2] is really the 2nd parameter passed to $file->ioctl(someReadOp\,$value).
Why would you use IO::Handle's ioctl function!? Why isn't this a function call? I see no reason to cloak all possible perl I/O functions in method calls. There's no benefit to writing
FH->ioctl(...) over ioctl(FH\, ...)
--tom
Hi\,
Why would you use IO::Handle's ioctl function!? Why isn't this a function call? I see no reason to cloak all possible perl I/O functions in method calls. There's no benefit to writing
FH\->ioctl\(\.\.\.\)
Because I got used to do my $file=new IO::File; $file->open $file->getline etc.
But I could very well live with an IO::Handle who doesn't implement any method except new\, and use my $file=new IO::File; open($file) \<$file> etc. if that is thought to be the preferred way of doing it.
I just think it's bad when $file->ioctl() looks like if it would work\, but then doesn't fully. Either fix it\, or throw it away.
claudio -- Claudio Nieder\, Kanalweg 1\, CH-8610 Uster \,'`.\,'`.\,'`.\,'`.\,'`.\,'`.\,'` mailto:private@claudio.ch http://www.claudio.ch phone:+41 79 357 6743
Migrated from rt.perl.org#2109 (status was 'resolved')
Searchable as RT2109$