Andrew Main (Zefram) > IO-ExplicitHandle > IO::ExplicitHandle

Download:
IO-ExplicitHandle-0.000.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

IO::ExplicitHandle - detect implicit I/O handles when compiling

SYNOPSIS ^

        use IO::ExplicitHandle;

        no IO::ExplicitHandle;

DESCRIPTION ^

This module provides a lexically-scoped pragma that prohibits I/O operations that use an implicit default I/O handle. For example, print 123 implicitly uses the "currently selected" I/O handle (controlled by select). Within the context of the pragma, I/O operations must be explicitly told which handle they are to operate on. For example, print STDOUT 123 explicitly uses the program's standard output stream.

The affected operations that use the "currently selected" I/O handle are print, printf, say, close, write, and the magic variables $|, $^, $~, $=, $-, and $%. The affected operations that use the "last read" I/O handle are eof, tell, and the magic variable $.. One form of the .. operator can implicitly read $., but it cannot be reliably distinguished at compile time from the more common list-generating form, so it is not affected by this module.

PACKAGE METHODS ^

IO::ExplicitHandle->import

Turns on the I/O handle stricture in the lexical environment that is currently compiling.

IO::ExplicitHandle->unimport

Turns off the I/O handle stricture in the lexical environment that is currently compiling.

BUGS ^

The .. operator decides only at runtime whether it will read from $., and hence implicitly use the "last read" I/O handle. It does this if called in scalar context. If the same expression is called in list context, it generates a list of numbers, unrelated to $.. This semantic overloading prevents the problematic use of .. being detected at compile time.

SEE ALSO ^

strict

AUTHOR ^

Andrew Main (Zefram) <zefram@fysh.org>

COPYRIGHT ^

Copyright (C) 2012 Andrew Main (Zefram) <zefram@fysh.org>

LICENSE ^

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: