名前¶
Test::Builder::IO::Scalar - A copy of IO::Scalar for Test::Builder
Test::Builder::IO::Scalar - Test::Builder のための IO::Scalar のコピー
説明¶
This is a copy of IO::Scalar which ships with Test::Builder to support scalar references as filehandles on Perl 5.6. Newer versions of Perl simply use <open()
>'s built in support.
これは、Perl 5.6 でファイルハンドルとしてのスカラリファレンス対応のために Test::Builder に同梱している IO::Scalar のコピーです。 より新しいバージョンの Perl では単に <open()
> の組み込み対応を使います。
Test::Builder can not have dependencies on other modules without careful consideration, so its simply been copied into the distribution.
Test::Builder は、注意深い考慮なしには他のモジュールへの依存を持てないので、 単に配布に含めるためにコピーしています。
COPYRIGHT and LICENSE¶
This file came from the "IO-stringy" Perl5 toolkit.
This file came from the "IO-stringy" Perl5 toolkit. (TBT)
Copyright (c) 1996 by Eryq. All rights reserved. Copyright (c) 1999,2001 by ZeeGee Software Inc. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Construction¶
- new [ARGS...]
-
Class method. Return a new, unattached scalar handle. If any arguments are given, they're sent to open().
Class method. Return a new, unattached scalar handle. If any arguments are given, they're sent to open(). (TBT)
- open [SCALARREF]
-
Instance method. Open the scalar handle on a new scalar, pointed to by SCALARREF. If no SCALARREF is given, a "private" scalar is created to hold the file data.
Instance method. Open the scalar handle on a new scalar, pointed to by SCALARREF. If no SCALARREF is given, a "private" scalar is created to hold the file data. (TBT)
Returns the self object on success, undefined on error.
Returns the self object on success, undefined on error. (TBT)
- opened
-
Instance method. Is the scalar handle opened on something?
Instance method. Is the scalar handle opened on something? (TBT)
- close
-
Instance method. Disassociate the scalar handle from its underlying scalar. Done automatically on destroy.
Instance method. Disassociate the scalar handle from its underlying scalar. Done automatically on destroy. (TBT)
Input and output¶
- flush
-
Instance method. No-op, provided for OO compatibility.
Instance method. No-op, provided for OO compatibility. (TBT)
- getc
-
Instance method. Return the next character, or undef if none remain.
Instance method. Return the next character, or undef if none remain. (TBT)
- getline
-
Instance method. Return the next line, or undef on end of string. Can safely be called in an array context. Currently, lines are delimited by "\n".
Instance method. Return the next line, or undef on end of string. Can safely be called in an array context. Currently, lines are delimited by "\n". (TBT)
- getlines
-
Instance method. Get all remaining lines. It will croak() if accidentally called in a scalar context.
Instance method. Get all remaining lines. It will croak() if accidentally called in a scalar context. (TBT)
- print ARGS...
-
Instance method. Print ARGS to the underlying scalar.
Instance method. Print ARGS to the underlying scalar. (TBT)
Warning: this continues to always cause a seek to the end of the string, but if you perform seek()s and tell()s, it is still safer to explicitly seek-to-end before subsequent print()s.
Warning: this continues to always cause a seek to the end of the string, but if you perform seek()s and tell()s, it is still safer to explicitly seek-to-end before subsequent print()s. (TBT)
- read BUF, NBYTES, [OFFSET]
-
Instance method. Read some bytes from the scalar. Returns the number of bytes actually read, 0 on end-of-file, undef on error.
Instance method. Read some bytes from the scalar. Returns the number of bytes actually read, 0 on end-of-file, undef on error. (TBT)
- write BUF, NBYTES, [OFFSET]
-
Instance method. Write some bytes to the scalar.
Instance method. Write some bytes to the scalar. (TBT)
- sysread BUF, LEN, [OFFSET]
-
Instance method. Read some bytes from the scalar. Returns the number of bytes actually read, 0 on end-of-file, undef on error.
Instance method. Read some bytes from the scalar. Returns the number of bytes actually read, 0 on end-of-file, undef on error. (TBT)
- syswrite BUF, NBYTES, [OFFSET]
-
Instance method. Write some bytes to the scalar.
Instance method. Write some bytes to the scalar. (TBT)
Seeking/telling and other attributes¶
- autoflush
-
Instance method. No-op, provided for OO compatibility.
Instance method. No-op, provided for OO compatibility. (TBT)
- binmode
-
Instance method. No-op, provided for OO compatibility.
Instance method. No-op, provided for OO compatibility. (TBT)
- clearerr
-
Instance method. Clear the error and EOF flags. A no-op.
Instance method. Clear the error and EOF flags. A no-op. (TBT)
- eof
-
Instance method. Are we at end of file?
Instance method. Are we at end of file? (TBT)
- seek OFFSET, WHENCE
-
Instance method. Seek to a given position in the stream.
Instance method. Seek to a given position in the stream. (TBT)
- sysseek OFFSET, WHENCE
-
Instance method. Identical to
seek OFFSET, WHENCE
, q.v.Instance method. Identical to
seek OFFSET, WHENCE
, q.v. (TBT) - tell
-
Instance method. Return the current position in the stream, as a numeric offset.
Instance method. Return the current position in the stream, as a numeric offset. (TBT)
- use_RS [YESNO]
-
Instance method. Deprecated and ignored. Obey the current setting of $/, like IO::Handle does? Default is false in 1.x, but cold-welded true in 2.x and later.
Instance method. Deprecated and ignored. Obey the current setting of $/, like IO::Handle does? Default is false in 1.x, but cold-welded true in 2.x and later. (TBT)
- setpos POS
-
Instance method. Set the current position, using the opaque value returned by
getpos()
.Instance method. Set the current position, using the opaque value returned by
getpos()
. (TBT) - getpos
-
Instance method. Return the current position in the string, as an opaque object.
Instance method. Return the current position in the string, as an opaque object. (TBT)
- sref
-
Instance method. Return a reference to the underlying scalar.
Instance method. Return a reference to the underlying scalar. (TBT)
WARNINGS¶
Perl's TIEHANDLE spec was incomplete prior to 5.005_57; it was missing support for seek()
, tell()
, and eof()
. Attempting to use these functions with an IO::Scalar will not work prior to 5.005_57. IO::Scalar will not have the relevant methods invoked; and even worse, this kind of bug can lie dormant for a while. If you turn warnings on (via $^W
or perl -w
), and you see something like this...
Perl's TIEHANDLE spec was incomplete prior to 5.005_57; it was missing support for seek()
, tell()
, and eof()
. Attempting to use these functions with an IO::Scalar will not work prior to 5.005_57. IO::Scalar will not have the relevant methods invoked; and even worse, this kind of bug can lie dormant for a while. If you turn warnings on (via $^W
or perl -w
), and you see something like this... (TBT)
attempt to seek on unopened filehandle
...then you are probably trying to use one of these functions on an IO::Scalar with an old Perl. The remedy is to simply use the OO version; e.g.:
...then you are probably trying to use one of these functions on an IO::Scalar with an old Perl. The remedy is to simply use the OO version; e.g.: (TBT)
$SH->seek(0,0); ### GOOD: will work on any 5.005
seek($SH,0,0); ### WARNING: will only work on 5.005_57 and beyond
VERSION¶
$Id$
作者¶
Primary Maintainer¶
David F. Skoll (dfs@roaringpenguin.com).
Principal author¶
Eryq (eryq@zeegee.com). President, ZeeGee Software Inc (http://www.zeegee.com).
Other contributors¶
The full set of contributors always includes the folks mentioned in "CHANGE LOG" in IO::Stringy. But just the same, special thanks to the following individuals for their invaluable contributions (if I've forgotten or misspelled your name, please email me!):
The full set of contributors always includes the folks mentioned in "CHANGE LOG" in IO::Stringy. But just the same, special thanks to the following individuals for their invaluable contributions (if I've forgotten or misspelled your name, please email me!): (TBT)
Andy Glew, for contributing getc()
.
Andy Glew, for contributing getc()
. (TBT)
Brandon Browning, for suggesting opened()
.
Brandon Browning, for suggesting opened()
. (TBT)
David Richter, for finding and fixing the bug in PRINTF()
.
David Richter, for finding and fixing the bug in PRINTF()
. (TBT)
Eric L. Brine, for his offset-using read() and write() implementations.
Eric L. Brine, for his offset-using read() and write() implementations. (TBT)
Richard Jones, for his patches to massively improve the performance of getline()
and add sysread
and syswrite
.
Richard Jones, for his patches to massively improve the performance of getline()
and add sysread
and syswrite
. (TBT)
B. K. Oxley (binkley), for stringification and inheritance improvements, and sundry good ideas.
B. K. Oxley (binkley), for stringification and inheritance improvements, and sundry good ideas. (TBT)
Doug Wilson, for the IO::Handle inheritance and automatic tie-ing.
Doug Wilson, for the IO::Handle inheritance and automatic tie-ing. (TBT)
SEE ALSO¶
IO::String, which is quite similar but which was designed more-recently and with an IO::Handle-like interface in mind, so you could mix OO- and native-filehandle usage without using tied().
IO::String, which is quite similar but which was designed more-recently and with an IO::Handle-like interface in mind, so you could mix OO- and native-filehandle usage without using tied(). (TBT)
Note: as of version 2.x, these classes all work like their IO::Handle counterparts, so we have comparable functionality to IO::String.
Note: as of version 2.x, these classes all work like their IO::Handle counterparts, so we have comparable functionality to IO::String. (TBT)