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