Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

[perl #31730] IO::File reads garbage from directory filehandles

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


perlbug-followup at perl

Nov 27, 2004, 7:36 AM

Post #1 of 1 (224 views)
Permalink
[perl #31730] IO::File reads garbage from directory filehandles

> [ni-s - Thu Sep 30 14:34:10 2004]:
>
> Steve Peters via RT <perlbug-followup[at]perl.org> writes:
> >
> >Two points brought up remain, though.
> >
> >* Do we want to add an optional argument to IO::File->new() so that it
> >fails on an open attempt on a directory? The advantage of this would
> >be that it would allow for consistant cross-platform behavior. This
> >would add some overhead to IO::File (likely a -d) to the constructor
> >for IO::File.
>
> >
> >* Do we want to document this behavior? Those who have bounced around
> >several POSIX environments have experienced this before and have
> >learned to deal with this behavior. Does this deserve mention on
> >IO::File's Pod, or is a FAQ entry sufficient?
>
> Personally I see no reason to use IO::File ever again so I don't care
> what you do to it, or its POD.
>
> I see some minor merit in mentioning amongst all the other
> perldoc -f open stuff.
> As for a FAQ entry, I don't remember this coming up
> before and I have been on p5p for (9?!) years so this isn't
> a very 'F' 'AQ'!
>

Below is a patch to explain the behavior and to suggest better alternatives.

--- /usr/libdata/perl5/i386-openbsd/5.8.5/IO/File.pm Fri Sep 17
13:09:59 2004
+++ ./IO/File.pm Sat Nov 27 09:32:46 2004
@@ -95,12 +95,20 @@

=back

+=head1 NOTE
+
+Some operating systems may allow a C<IO::File::new> or C<IO::File::open>
+to be performed on a directory without errors. This behavior is not
+portable and not suggested for use. Instead, C<opendir> and C<readdir> or
+C<DirHandle> suggested instead.
+
=head1 SEE ALSO

L<perlfunc>,
L<perlop/"I/O Operators">,
L<IO::Handle>
L<IO::Seekable>
+L<DirHandle>

=head1 HISTORY

@@ -121,7 +129,7 @@

@ISA = qw(IO::Handle IO::Seekable Exporter);

-$VERSION = "1.10";
+$VERSION = "1.11";

@EXPORT = @IO::Seekable::EXPORT;

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.