-
-
03 May 2022 15:41:11 UTC
- Distribution: IO
- Module version: 1.49
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues
- Testers (564 / 72 / 0)
- Kwalitee
Bus factor: 5- 62.46% Coverage
- License: perl_5
- Activity
24 month- Tools
- Download (184.43KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- File::Temp
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
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
provides an object constructor and methods, which are just wrappers around perl's built in directory reading routines.- new ( [ DIRNAME ] )
-
new
is the constructor forIO::Dir
objects. It accepts one optional argument which, if given,new
will pass toopen
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.
IO::Dir
also provides an interface to reading directories via a tied hash. The tied hash extends the interface beyond just the directory reading routines by the use oflstat
, from theFile::stat
package,unlink
,rmdir
andutime
.The keys of the hash will be the names of the entries in the directory. Reading a value from the hash will be the result of calling
File::stat::lstat
. Deleting an element from the hash will delete the corresponding file or subdirectory, provided thatDIR_UNLINK
is included in theOPTIONS
.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 modification 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 modification time.
SEE ALSO
AUTHOR
Graham Barr. Currently maintained by the Perl Porters. Please report all bugs at https://github.com/Perl/perl5/issues.
COPYRIGHT
Copyright (c) 1997-2003 Graham Barr <gbarr@pobox.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Module Install Instructions
To install IO, copy and paste the appropriate command in to your terminal.
cpanm IO
perl -MCPAN -e shell install IO
For more information on module installation, please visit the detailed CPAN module installation guide.