home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd1.bin / zkuste / Perl / ActivePerl-5.6.0.613.msi / 䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥 / _5333226655ead7eef54c1b70216ef777 < prev    next >
Text File  |  2000-03-23  |  4KB  |  126 lines

  1.  
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Tie::Dir - class definition for reading directories via a tied hash</TITLE>
  5. <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
  6. <LINK REV="made" HREF="mailto:">
  7. </HEAD>
  8.  
  9. <BODY>
  10. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  11. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  12. <STRONG><P CLASS=block> Tie::Dir - class definition for reading directories via a tied hash</P></STRONG>
  13. </TD></TR>
  14. </TABLE>
  15.  
  16. <A NAME="__index__"></A>
  17. <!-- INDEX BEGIN -->
  18.  
  19. <UL>
  20.  
  21.     <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
  22.  
  23.     <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
  24.     <LI><A HREF="#description">DESCRIPTION</A></LI>
  25.     <LI><A HREF="#author">AUTHOR</A></LI>
  26. </UL>
  27. <!-- INDEX END -->
  28.  
  29. <HR>
  30. <P>
  31. <H1><A NAME="name">NAME</A></H1>
  32. <P>Tie::Dir - class definition for reading directories via a tied hash</P>
  33. <P>
  34. <HR>
  35. <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
  36. <UL>
  37. <LI>Linux</LI>
  38. <LI>Solaris</LI>
  39. <LI>Windows</LI>
  40. </UL>
  41. <HR>
  42. <H1><A NAME="synopsis">SYNOPSIS</A></H1>
  43. <PRE>
  44.         use Tie::Dir qw(DIR_UNLINK);
  45. </PRE>
  46. <PRE>
  47.  
  48.         # Both of these produce identical results
  49.         #(ie %hash is tied)
  50.         tie %hash, Tie::Dir, ".", DIR_UNLINK;
  51.         new Tie::Dir \%hash, ".", DIR_UNLINK;</PRE>
  52. <PRE>
  53.  
  54.         # This creates a reference to a hash, which is tied.
  55.         $hash = new Tie::Dir ".";</PRE>
  56. <PRE>
  57.  
  58.         # All these examples assume that %hash is tied (ie one of the
  59.         # first two tie methods was used</PRE>
  60. <PRE>
  61.  
  62.         # itterate through the directory
  63.         foreach $file ( keys %hash ) {
  64.                 ...
  65.         }</PRE>
  66. <PRE>
  67.  
  68.         # Set the access and modification times (touch :-)
  69.         $hash{SomeFile} = time;</PRE>
  70. <PRE>
  71.  
  72.         # Obtain stat information of a file
  73.         @stat = @{$hash{SomeFile}};</PRE>
  74. <PRE>
  75.  
  76.         # Check if entry exists
  77.         if(exists $hash{SomeFile}) {
  78.                 ...
  79.         }</PRE>
  80. <PRE>
  81.  
  82.         # Delete an entry, only if DIR_UNLINK specified
  83.         delete $hash{SomeFile};</PRE>
  84. <P>
  85. <HR>
  86. <H1><A NAME="description">DESCRIPTION</A></H1>
  87. <P>This module provides a method of reading directories using a hash.</P>
  88. <P>The keys of the hash are the directory entries and the values are a
  89. reference to an array which holds the result of <A HREF="../../../lib/Pod/perlfunc.html#item_stat"><CODE>stat</CODE></A> being called
  90. on the entry.</P>
  91. <P>The access and modification times of an entry can be changed by assigning
  92. to an element of the hash. If a single number is assigned then the access
  93. and modification times will both be set to the same value, alternatively
  94. the access and modification times may be set separetly by passing a 
  95. reference to an array with 2 entries, the first being the access time
  96. and the second being the modification time.</P>
  97. <DL>
  98. <DT><STRONG><A NAME="item_new_%5Bhashref%2C%5D_dirname_%5B%2C_options%5D">new [hashref,] dirname [, options]</A></STRONG><BR>
  99. <DD>
  100. This method ties the hash referenced by <CODE>hashref</CODE> to the directory <CODE>dirname</CODE>.
  101. If <CODE>hashref</CODE> is omitted then <CODE>new</CODE> returns a reference to a hash which
  102. hash been tied, otherwise it returns the result of <A HREF="../../../lib/Pod/perlfunc.html#item_tie"><CODE>tie</CODE></A>
  103. <P>The possible options are:</P>
  104. <DL>
  105. <DT><STRONG><A NAME="item_DIR_UNLINK">DIR_UNLINK</A></STRONG><BR>
  106. <DD>
  107. Delete operations on the hash will cause <A HREF="../../../lib/Pod/perlfunc.html#item_unlink"><CODE>unlink</CODE></A> to be called on the
  108. corresponding file
  109. <P></P></DL>
  110. </DL>
  111. <P>
  112. <HR>
  113. <H1><A NAME="author">AUTHOR</A></H1>
  114. <P>Graham Barr <<A HREF="mailto:bodg@tiuk.ti.com">bodg@tiuk.ti.com</A>>, from a quick hack posted by 
  115. Kenneth Albanowski <<A HREF="mailto:kjahds@kjahds.com">kjahds@kjahds.com</A>>  to the perl5-porters mailing list
  116. based on a neat idea by Ilya Zakharevich.</P>
  117. <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
  118. <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
  119. <STRONG><P CLASS=block> Tie::Dir - class definition for reading directories via a tied hash</P></STRONG>
  120. </TD></TR>
  121. </TABLE>
  122.  
  123. </BODY>
  124.  
  125. </HTML>
  126.