use Chj::xopen;
        my $in = xopen_read "foo.txt";
        my $out = glob_to_fh(*STDOUT,"utf-8");
        local $_;
        while (<$in>) { # default operation. (overload not possible :/)
            $out->xprint($_); # print, throwing an exception on error
        $out->xclose; # close explicitely, throwing an exception on error
      # $in and $out are closed automatically in any case
      # (issuing a warning on error)


Constructors around Chj::IO::File.


xopen ( EXPR | MODE,LIST )

Open the given file like the perl builtin "open" or croak on errors. Returns an anonymous symbol blessed into Chj::xopen::file, which can be used both as object or filehandle (more correctly: anonymous glob) (? always? Perl is a bit complicated when handling filehandles in indirect object notation).

(BTW, note that perl won't give an error if you open a directory instead of a file for reading. The returned filehandle will give empty results if either used with read or readdir. That's true for perl 5.005x - 5.6.1 on linux.)

xopen_read EXPR
xopen_write EXPR
xopen_append EXPR
xopen_update EXPR

Those *optionally exported* functions check the one given input parameter for <>+ chars at the beginning, and either croak if they don't match the purpose of the function, or prepend the right chars if missing.

stdin, stdout, stderr

The functions with these names call glob_to_fh(*STD..., "utf-8") by default. If given an argument, it is used as the encoding instead of "utf-8".


Stuff like >&1 not yet really supported by the above xopen_* functions.


Chj::IO::File, Chj::xsysopen, Chj::xopendir


This is alpha software! Read the status section in the package README or on the website.