home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Stringy.pm < prev    next >
Encoding:
Perl POD Document  |  2003-12-29  |  12.5 KB  |  431 lines

  1. package IO::Stringy;
  2.  
  3. use vars qw($VERSION);
  4. $VERSION = substr q$Revision: 2.109 $, 10;
  5.  
  6. 1;
  7. __END__
  8.  
  9.  
  10. =head1 NAME
  11.  
  12. IO-stringy - I/O on in-core objects like strings and arrays
  13.  
  14.  
  15. =head1 SYNOPSIS
  16.  
  17.     IO::
  18.     ::AtomicFile   adpO  Write a file which is updated atomically     ERYQ
  19.     ::Lines        bdpO  I/O handle to read/write to array of lines   ERYQ
  20.     ::Scalar       RdpO  I/O handle to read/write to a string         ERYQ
  21.     ::ScalarArray  RdpO  I/O handle to read/write to array of scalars ERYQ
  22.     ::Wrap         RdpO  Wrap old-style FHs in standard OO interface  ERYQ
  23.     ::WrapTie      adpO  Tie your handles & retain full OO interface  ERYQ
  24.  
  25.  
  26. =head1 DESCRIPTION
  27.  
  28. This toolkit primarily provides modules for performing both traditional
  29. and object-oriented i/o) on things I<other> than normal filehandles;
  30. in particular, L<IO::Scalar|IO::Scalar>, L<IO::ScalarArray|IO::ScalarArray>,
  31. and L<IO::Lines|IO::Lines>.
  32.  
  33. In the more-traditional IO::Handle front, we
  34. have L<IO::AtomicFile|IO::AtomicFile>
  35. which may be used to painlessly create files which are updated
  36. atomically.
  37.  
  38. And in the "this-may-prove-useful" corner, we have L<IO::Wrap|IO::Wrap>,
  39. whose exported wraphandle() function will clothe anything that's not
  40. a blessed object in an IO::Handle-like wrapper... so you can just
  41. use OO syntax and stop worrying about whether your function's caller
  42. handed you a string, a globref, or a FileHandle.
  43.  
  44.  
  45. =head1 WARNINGS
  46.  
  47. Perl's TIEHANDLE spec was incomplete prior to 5.005_57;
  48. it was missing support for C<seek()>, C<tell()>, and C<eof()>.
  49. Attempting to use these functions with an IO::Scalar, IO::ScalarArray,
  50. IO::Lines, etc. B<will not work> prior to 5.005_57.
  51. None of the relevant methods will be invoked by Perl;
  52. and even worse, this kind of bug can lie dormant for a while.
  53. If you turn warnings on (via C<$^W> or C<perl -w>), and you see
  54. something like this...
  55.  
  56.     seek() on unopened file
  57.  
  58. ...then you are probably trying to use one of these functions
  59. on one of our IO:: classes with an old Perl.  The remedy is to simply
  60. use the OO version; e.g.:
  61.  
  62.     $SH->seek(0,0);    ### GOOD: will work on any 5.005
  63.     seek($SH,0,0);     ### WARNING: will only work on 5.005_57 and beyond
  64.  
  65.  
  66.  
  67. =head1 INSTALLATION
  68.  
  69.  
  70. =head2 Requirements
  71.  
  72. As of version 2.x, this toolkit requires Perl 5.005 for
  73. the IO::Handle subclasses, and 5.005_57 or better is
  74. B<strongly> recommended.  See L<"WARNINGS"> for details.
  75.  
  76.  
  77. =head2 Directions
  78.  
  79. Most of you already know the drill...
  80.  
  81.     perl Makefile.PL
  82.     make
  83.     make test
  84.     make install
  85.  
  86. For everyone else out there...
  87. if you've never installed Perl code before, or you're trying to use
  88. this in an environment where your sysadmin or ISP won't let you do
  89. interesting things, B<relax:> since this module contains no binary
  90. extensions, you can cheat.  That means copying the directory tree
  91. under my "./lib" directory into someplace where your script can "see"
  92. it.  For example, under Linux:
  93.  
  94.     cp -r IO-stringy-1.234/lib/* /path/to/my/perl/
  95.  
  96. Now, in your Perl code, do this:
  97.  
  98.     use lib "/path/to/my/perl";
  99.     use IO::Scalar;                   ### or whatever
  100.  
  101. Ok, now you've been told.  At this point, anyone who whines about
  102. not being given enough information gets an unflattering haiku
  103. written about them in the next change log.  I'll do it.
  104. Don't think I won't.
  105.  
  106.  
  107.  
  108. =head1 VERSION
  109.  
  110. $Id: Stringy.pm,v 2.109 2003/12/21 18:51:45 eryq Exp $
  111.  
  112.  
  113.  
  114. =head1 TO DO
  115.  
  116. =over 4
  117.  
  118. =item (2000/08/02)  Finalize $/ support
  119.  
  120. Graham Barr submitted this patch half a I<year> ago;
  121. Like a moron, I lost his message under a ton of others,
  122. and only now have the experimental implementation done.
  123.  
  124. Will the sudden sensitivity to $/ hose anyone out there?
  125. I'm worried, so you have to enable it explicitly in 1.x.
  126. It will be on by default in 2.x, though only IO::Scalar
  127. has been implemented.
  128.  
  129.  
  130. =item (2000/09/28)  Separate read/write cursors?
  131.  
  132. Binkley sent me a very interesting variant of IO::Scalar which
  133. maintains two separate cursors on the data, one for reading
  134. and one for writing.  Quoth he:
  135.  
  136.     Isn't it the case that real operating system file descriptors
  137.     maintain an independent read and write file position (and
  138.     seek(2) resets them both)?
  139.  
  140. (My answer: perhaps, but stdio's fseek/ftell manpages seem to
  141. imply a single file position indicator, and I'm trying to be IO::-ish.)
  142. Binkley also pointed out some issues with his implementation:
  143.  
  144.     For example, what does eof or tell return?  The read position or
  145.     the write position?  (I assumed read position was more important).
  146.  
  147. Your opinions on this are most welcome.
  148. (Me, I'm just squeamish that this will break some code
  149. which depends on the existing behavior, and that attempts to
  150. maintain backwards-compatibility will slow down the code.)
  151.  
  152.  
  153. =item (2001/08/08)  Remove IO::WrapTie from new IO:: classes
  154.  
  155. It's not needed.  Backwards compatibility could be maintained
  156. by having new_tie() be identical to new().  Heck, I'll bet
  157. that IO::WrapTie should be reimplemented so the returned
  158. object is just like an IO::Scalar in its use of globrefs.
  159.  
  160.  
  161. =back
  162.  
  163.  
  164.  
  165. =head1 CHANGE LOG
  166.  
  167. =over 4
  168.  
  169.  
  170. =item Version 2.109   (2003/12/21)
  171.  
  172. IO::Scalar::getline now works with ref to int.
  173. I<Thanks to Dominique Quatravaux for this patch.>
  174.  
  175.  
  176. =item Version 2.108   (2001/08/20)
  177.  
  178. The terms-of-use have been placed in the distribution file "COPYING".
  179. Also, small documentation tweaks were made.
  180.  
  181.  
  182. =item Version 2.105   (2001/08/09)
  183.  
  184. Added support for various seek() whences to IO::ScalarArray.
  185.  
  186. Added support for consulting $/ in IO::Scalar and IO::ScalarArray.
  187. The old C<use_RS()> is not even an option.
  188. Unsupported record separators will cause a croak().
  189.  
  190. Added a lot of regression tests to supoprt the above.
  191.  
  192. Better on-line docs (hyperlinks to individual functions).
  193.  
  194.  
  195. =item Version 2.103   (2001/08/08)
  196.  
  197. After sober consideration I have reimplemented IO::Scalar::print()
  198. so that it once again always seeks to the end of the string.
  199. Benchmarks show the new implementation to be just as fast as
  200. Juergen's contributed patch; until someone can convince me otherwise,
  201. the current, safer implementation stays.
  202.  
  203. I thought more about giving IO::Scalar two separate handles,
  204. one for reading and one for writing, as suggested by Binkley.
  205. His points about what tell() and eof() return are, I think,
  206. show-stoppers for this feature.  Even the manpages for stdio's fseek()
  207. seem to imply a I<single> file position indicator, not two.
  208. So I think I will take this off the TO DO list.
  209. B<Remedy:> you can always have two handles open on the same
  210. scalar, one which you only write to, and one which you only read from.
  211. That should give the same effect.
  212.  
  213.  
  214. =item Version 2.101   (2001/08/07)
  215.  
  216. B<Alpha release.>
  217. This is the initial release of the "IO::Scalar and friends are
  218. now subclasses of IO::Handle".  I'm flinging it against the wall.
  219. Please tell me if the banana sticks.  When it does, the banana
  220. will be called 2.2x.
  221.  
  222. First off, I<many many thanks to Doug Wilson>, who
  223. has provided an I<invaluable> service by patching IO::Scalar
  224. and friends so that they (1) inherit from IO::Handle, (2) automatically
  225. tie themselves so that the C<new()> objects can be used in native i/o
  226. constructs, and (3) doing it so that the whole damn thing passes
  227. its regression tests.  As Doug knows, my globref Kung-Fu was not
  228. up to the task; he graciously provided the patches.  This has earned
  229. him a seat at the L<Co-Authors|"AUTHOR"> table, and the
  230. right to have me address him as I<sensei>.
  231.  
  232. Performance of IO::Scalar::print() has been improved by as much as 2x
  233. for lots of little prints, with the cost of forcing those
  234. who print-then-seek-then-print to explicitly seek to end-of-string
  235. before printing again.
  236. I<Thanks to Juergen Zeller for this patch.>
  237.  
  238. Added the COPYING file, which had been missing from prior versions.
  239. I<Thanks to Albert Chin-A-Young for pointing this out.>
  240.  
  241. IO::Scalar consults $/ by default (1.x ignored it by default).
  242. Yes, I still need to support IO::ScalarArray.
  243.  
  244.  
  245. =item Version 1.221   (2001/08/07)
  246.  
  247. I threatened in L<"INSTALLATION"> to write an unflattering haiku
  248. about anyone who whined that I gave them insufficient information...
  249. but it turns out that I left out a crucial direction.  D'OH!
  250. I<Thanks to David Beroff for the "patch" and the haiku...>
  251.  
  252.        Enough info there?
  253.          Here's unflattering haiku:
  254.        Forgot the line, "make"!  ;-)
  255.  
  256.  
  257.  
  258. =item Version 1.220   (2001/04/03)
  259.  
  260. Added untested SEEK, TELL, and EOF methods to IO::Scalar
  261. and IO::ScalarArray to support corresponding functions for
  262. tied filehandles: untested, because I'm still running 5.00556
  263. and Perl is complaining about "tell() on unopened file".
  264. I<Thanks to Graham Barr for the suggestion.>
  265.  
  266. Removed not-fully-blank lines from modules; these were causing
  267. lots of POD-related warnings.
  268. I<Thanks to Nicolas Joly for the suggestion.>
  269.  
  270.  
  271. =item Version 1.219   (2001/02/23)
  272.  
  273. IO::Scalar objects can now be made sensitive to $/ .
  274. Pains were taken to keep the fast code fast while adding this feature.
  275. I<Cheers to Graham Barr for submitting his patch;
  276. jeers to me for losing his email for 6 months.>
  277.  
  278.  
  279. =item Version 1.218   (2001/02/23)
  280.  
  281. IO::Scalar has a new sysseek() method.
  282. I<Thanks again to Richard Jones.>
  283.  
  284. New "TO DO" section, because people who submit patches/ideas should
  285. at least know that they're in the system... and that I won't lose
  286. their stuff.  Please read it.
  287.  
  288. New entries in L<"AUTHOR">.
  289. Please read those too.
  290.  
  291.  
  292.  
  293. =item Version 1.216   (2000/09/28)
  294.  
  295. B<IO::Scalar and IO::ScalarArray now inherit from IO::Handle.>
  296. I thought I'd remembered a problem with this ages ago, related to
  297. the fact that these IO:: modules don't have "real" filehandles,
  298. but the problem apparently isn't surfacing now.
  299. If you suddenly encounter Perl warnings during global destruction
  300. (especially if you're using tied filehandles), then please let me know!
  301. I<Thanks to B. K. Oxley (binkley) for this.>
  302.  
  303. B<Nasty bug fixed in IO::Scalar::write().>
  304. Apparently, the offset and the number-of-bytes arguments were,
  305. for all practical purposes, I<reversed.>  You were okay if
  306. you did all your writing with print(), but boy was I<this> a stupid bug!
  307. I<Thanks to Richard Jones for finding this one.
  308. For you, Rich, a double-length haiku:>
  309.  
  310.        Newspaper headline
  311.           typeset by dyslexic man
  312.        loses urgency
  313.  
  314.        BABY EATS FISH is
  315.           simply not equivalent
  316.        to FISH EATS BABY
  317.  
  318. B<New sysread and syswrite methods for IO::Scalar.>
  319. I<Thanks again to Richard Jones for this.>
  320.  
  321.  
  322. =item Version 1.215   (2000/09/05)
  323.  
  324. Added 'bool' overload to '""' overload, so object always evaluates
  325. to true.  (Whew.  Glad I caught this before it went to CPAN.)
  326.  
  327.  
  328. =item Version 1.214   (2000/09/03)
  329.  
  330. Evaluating an IO::Scalar in a string context now yields
  331. the underlying string.
  332. I<Thanks to B. K. Oxley (binkley) for this.>
  333.  
  334.  
  335. =item Version 1.213   (2000/08/16)
  336.  
  337. Minor documentation fixes.
  338.  
  339.  
  340. =item Version 1.212   (2000/06/02)
  341.  
  342. Fixed IO::InnerFile incompatibility with Perl5.004.
  343. I<Thanks to many folks for reporting this.>
  344.  
  345.  
  346. =item Version 1.210   (2000/04/17)
  347.  
  348. Added flush() and other no-op methods.
  349. I<Thanks to Doru Petrescu for suggesting this.>
  350.  
  351.  
  352. =item Version 1.209   (2000/03/17)
  353.  
  354. Small bug fixes.
  355.  
  356.  
  357. =item Version 1.208   (2000/03/14)
  358.  
  359. Incorporated a number of contributed patches and extensions,
  360. mostly related to speed hacks, support for "offset", and
  361. WRITE/CLOSE methods.
  362. I<Thanks to Richard Jones, Doru Petrescu, and many others.>
  363.  
  364.  
  365.  
  366. =item Version 1.206   (1999/04/18)
  367.  
  368. Added creation of ./testout when Makefile.PL is run.
  369.  
  370.  
  371. =item Version 1.205   (1999/01/15)
  372.  
  373. Verified for Perl5.005.
  374.  
  375.  
  376. =item Version 1.202   (1998/04/18)
  377.  
  378. New IO::WrapTie and IO::AtomicFile added.
  379.  
  380.  
  381. =item Version 1.110
  382.  
  383. Added IO::WrapTie.
  384.  
  385.  
  386. =item Version 1.107
  387.  
  388. Added IO::Lines, and made some bug fixes to IO::ScalarArray.
  389. Also, added getc().
  390.  
  391.  
  392. =item Version 1.105
  393.  
  394. No real changes; just upgraded IO::Wrap to have a $VERSION string.
  395.  
  396. =back
  397.  
  398.  
  399.  
  400.  
  401. =head1 AUTHOR
  402.  
  403. =over 4
  404.  
  405. =item Primary Maintainer
  406.  
  407. Eryq (F<eryq@zeegee.com>).
  408. President, ZeeGee Software Inc (F<http://www.zeegee.com>).
  409.  
  410. =item Co-Authors
  411.  
  412. For all their bug reports and patch submissions, the following
  413. are officially recognized:
  414.  
  415.      Richard Jones
  416.      B. K. Oxley (binkley)
  417.      Doru Petrescu
  418.      Doug Wilson (for picking up the ball I dropped, and doing tie() right)
  419.  
  420.  
  421. =back
  422.  
  423. Go to F<http://www.zeegee.com> for the latest downloads
  424. and on-line documentation for this module.
  425.  
  426. Enjoy.  Yell if it breaks.
  427.  
  428.  
  429. =cut
  430.  
  431.