unixdev.net


Switch to SpeakEasy.net DSL

The Modular Manual Browser

Home Page
Manual: (OpenBSD-3.6)
Page:
Section:
Apropos / Subsearch:
optional field



IO::Dir(3p)      Perl Programmers Reference Guide     IO::Dir(3p)


NAME
       IO::Dir - supply object methods for directory handles

SYNOPSIS
           use IO::Dir;
           $d = IO::Dir->new(".");
           if (defined $d) {
               while (defined($_ = $d->read)) { something($_); }
               $d->rewind;
               while (defined($_ = $d->read)) { something_else($_); }
               undef $d;
           }

           tie %dir, 'IO::Dir', ".";
           foreach (keys %dir) {
               print $_, " " , $dir{$_}->size,"\n";
           }

DESCRIPTION
       The "IO::Dir" package provides two interfaces to perl's
       directory reading routines.

       The first interface is an object approach. "IO::Dir" pro-
       vides an object constructor and methods, which are just
       wrappers around perl's built in directory reading rou-
       tines.

       new ( [ DIRNAME ] )
           "new" is the constuctor for "IO::Dir" objects. It
           accepts one optional argument which,  if given, "new"
           will pass to "open"

       The following methods are wrappers for the directory
       related functions built into perl (the trailing `dir' has
       been removed from the names). See perlfunc for details of
       these functions.

       open ( DIRNAME )
       read ()
       seek ( POS )
       tell ()
       rewind ()
       close ()

       "IO::Dir" also provides an interface to reading directo-
       ries via a tied hash. The tied hash extends the interface
       beyond just the directory reading routines by the use of
       "lstat", from the "File::stat" package, "unlink", "rmdir"
       and "utime".

       tie %hash, 'IO::Dir', DIRNAME [, OPTIONS ]

       The keys of the hash will be the names of the entries in
       the directory.  Reading a value from the hash will be the



perl v5.8.5                 2002-11-06                          1





IO::Dir(3p)      Perl Programmers Reference Guide     IO::Dir(3p)


       result of calling "File::stat::lstat".  Deleting an ele-
       ment from the hash will delete the corresponding file or
       subdirectory, provided that "DIR_UNLINK" is included in
       the "OPTIONS".

       Assigning to an entry in the hash will cause the time
       stamps of the file to be modified. If the file does not
       exist then it will be created. Assigning a single integer
       to a hash element will cause both the access and modifica-
       tion times to be changed to that value. Alternatively a
       reference to an array of two values can be passed. The
       first array element will be used to set the access time
       and the second element will be used to set the modifica-
       tion time.

SEE ALSO
       File::stat

AUTHOR
       Graham Barr. Currently maintained by the Perl Porters.
       Please report all bugs to <perl5-portersATperl.org>.

COPYRIGHT
       Copyright (c) 1997-2003 Graham Barr <gbarrATpobox.com>. All
       rights reserved.  This program is free software; you can
       redistribute it and/or modify it under the same terms as
       Perl itself.






























perl v5.8.5                 2002-11-06                          2