IO::Null man page on Fedora

Man page or keyword search:  
man Server   31170 pages
apropos Keyword Search (all sections)
Output format
Fedora logo
[printable version]

IO::Null(3)	      User Contributed Perl Documentation	   IO::Null(3)

NAME
       IO::Null -- class for null filehandles

SYNOPSIS
	 use IO::Null;
	 my $fh = IO::Null->new;
	 print $fh "I have nothing to say\n";  # does nothing.
	 # or:
	 $fh->print("And I'm saying it.\n");   # ditto.
	 # or:
	 my $old = select($fh);
	 print "and that is poetry / as I needed it --John Cage"; # nada!
	 select($old);

       Or even:

	 tie(*FOO, IO::Null);
	 print FOO "Lalalalala!\n";  # does nothing.

DESCRIPTION
       This is a class for null filehandles.

       Calling a constructor of this class always succeeds, returning a new
       null filehandle.

       Writing to any object of this class is always a no-operation, and
       returns true.

       Reading from any object of this class is always no-operation, and
       returns empty-string or empty-list, as appropriate.

WHY
       You could say:

	 open(NULL, '>/dev/null') || die "WHAAT?! $!";

       and get a null FH that way.  But not everyone is using an OS that has a
       "/dev/null"

IMPLEMENTATION
       This is a subclass of IO::Handle.  Applicable methods with subs that do
       nothing, and return an appropriate value.

SEE ALSO
       IO::Handle, perltie, IO::Scalar

CAVEATS
       * This:

	 use IO::Null;
	 $^W = 1;  # turn on warnings
	 tie(*FOO, IO::Null);
	 print FOO "Lalalalala!\n";  # does nothing.
	 untie(*FOO);

       has been known to produce this odd warning:

	 untie attempted while 3 inner references still exist.

       and I've no idea why.

       * Furthermore, this:

	 use IO::Null;
	 $^W = 1;
	 *FOO = IO::Null->new;
	 print FOO "Lalalalala!\n";  # does nothing.
	 close(FOO);

       emits these warnings:

	 Filehandle main::FOO never opened.
	 Close on unopened file <GLOB>.

       ...which are, in fact, true; the FH behind the FOO{IO} was never opened
       on any real filehandle.	(I'd welcome anyone's (working) suggestions on
       how to suppress these warnings.)

       You get the same warnings with:

	 use IO::Null;
	 $^W = 1;
	 my $fh = IO::Null->new;
	 print $fh "Lalalalala!\n";  # does nothing.
	 close $fh;

       Note that this, however:

	 use IO::Null;
	 $^W = 1;
	 my $fh = IO::Null->new;
	 $fh->print("Lalalalala!\n");  # does nothing.
	 $fh->close();

       emits no warnings.

       * I don't know if you can successfully untaint a null filehandle.

       * This:

	 $null_fh->fileno

       will return a defined and nonzero number, but one you're not likely to
       want to use for anything.  See the source.

       * These docs are longer than the source itself.	Read the source!

COPYRIGHT
       Copyright (c) 2000 Sean M. Burke. All rights reserved.

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

AUTHOR
       Sean M. Burke "sburke@cpan.org"

perl v5.14.0			  2004-12-30			   IO::Null(3)
[top]

List of man pages available for Fedora

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net