home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Tie::Dir - class definition for reading directories via a tied hash</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tie::Dir - class definition for reading directories via a tied hash</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Tie::Dir - class definition for reading directories via a tied hash</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- use Tie::Dir qw(DIR_UNLINK);
- </PRE>
- <PRE>
-
- # Both of these produce identical results
- #(ie %hash is tied)
- tie %hash, Tie::Dir, ".", DIR_UNLINK;
- new Tie::Dir \%hash, ".", DIR_UNLINK;</PRE>
- <PRE>
-
- # This creates a reference to a hash, which is tied.
- $hash = new Tie::Dir ".";</PRE>
- <PRE>
-
- # All these examples assume that %hash is tied (ie one of the
- # first two tie methods was used</PRE>
- <PRE>
-
- # itterate through the directory
- foreach $file ( keys %hash ) {
- ...
- }</PRE>
- <PRE>
-
- # Set the access and modification times (touch :-)
- $hash{SomeFile} = time;</PRE>
- <PRE>
-
- # Obtain stat information of a file
- @stat = @{$hash{SomeFile}};</PRE>
- <PRE>
-
- # Check if entry exists
- if(exists $hash{SomeFile}) {
- ...
- }</PRE>
- <PRE>
-
- # Delete an entry, only if DIR_UNLINK specified
- delete $hash{SomeFile};</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This module provides a method of reading directories using a hash.</P>
- <P>The keys of the hash are the directory entries and the values are a
- reference to an array which holds the result of <A HREF="../../../lib/Pod/perlfunc.html#item_stat"><CODE>stat</CODE></A> being called
- on the entry.</P>
- <P>The access and modification times of an entry can be changed by assigning
- to an element of the hash. If a single number is assigned then the access
- and modification times will both be set to the same value, alternatively
- the access and modification times may be set separetly by passing a
- reference to an array with 2 entries, the first being the access time
- and the second being the modification time.</P>
- <DL>
- <DT><STRONG><A NAME="item_new_%5Bhashref%2C%5D_dirname_%5B%2C_options%5D">new [hashref,] dirname [, options]</A></STRONG><BR>
- <DD>
- This method ties the hash referenced by <CODE>hashref</CODE> to the directory <CODE>dirname</CODE>.
- If <CODE>hashref</CODE> is omitted then <CODE>new</CODE> returns a reference to a hash which
- hash been tied, otherwise it returns the result of <A HREF="../../../lib/Pod/perlfunc.html#item_tie"><CODE>tie</CODE></A>
- <P>The possible options are:</P>
- <DL>
- <DT><STRONG><A NAME="item_DIR_UNLINK">DIR_UNLINK</A></STRONG><BR>
- <DD>
- Delete operations on the hash will cause <A HREF="../../../lib/Pod/perlfunc.html#item_unlink"><CODE>unlink</CODE></A> to be called on the
- corresponding file
- <P></P></DL>
- </DL>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Graham Barr <<A HREF="mailto:bodg@tiuk.ti.com">bodg@tiuk.ti.com</A>>, from a quick hack posted by
- Kenneth Albanowski <<A HREF="mailto:kjahds@kjahds.com">kjahds@kjahds.com</A>> to the perl5-porters mailing list
- based on a neat idea by Ilya Zakharevich.</P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Tie::Dir - class definition for reading directories via a tied hash</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-