Chj::xopen
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.
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.)
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.
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.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.