ext/IO/lib/IO/t/io_tell.t See if seek()/tell()-related methods from IO work
ext/IO/lib/IO/t/io_udp.t See if UDP socket-related methods from IO work
ext/IO/lib/IO/t/io_unix.t See if UNIX socket-related methods from IO work
+ext/IO/lib/IO/t/io_utf8.t See if perlio opens work
ext/IO/lib/IO/t/io_xs.t See if XSUB methods from IO work
ext/IO/Makefile.PL IO extension makefile writer
ext/IO/poll.c IO poll() emulation using select()
=item open( FILENAME [,MODE [,PERMS]] )
+=item open( FILENAME, IOLAYERS )
+
C<open> accepts one, two or three parameters. With one parameter,
it is just a front end for the built-in C<open> function. With two or three
parameters, the first parameter is a filename that may include
and the optional permissions value to the Perl C<sysopen> operator.
The permissions default to 0666.
+If C<IO::File::open> is given a mode that includes the C<:> character,
+it passes all the three arguments to the three-argument C<open> operator.
+
For convenience, C<IO::File> exports the O_XXX constants from the
Fcntl module, if this module is available.
if ($mode =~ /^\d+$/) {
defined $perms or $perms = 0666;
return sysopen($fh, $file, $mode, $perms);
+ } elsif ($mode =~ /:/) {
+ return open($fh, $mode, $file) if @_ == 3;
+ croak 'usage: $fh->open(FILENAME, IOLAYERS)';
}
if (defined($file) && length($file)
&& ! File::Spec->file_name_is_absolute($file))
--- /dev/null
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ unless (find PerlIO::Layer 'perlio') {
+ print "1..0 # Skip: not perlio\n";
+ exit 0;
+ }
+}
+
+require "./test.pl";
+
+plan(tests => 5);
+
+my $io;
+
+use_ok('IO::File');
+
+$io = IO::File->new;
+
+ok($io->open("io_utf8", ">:utf8"), "open >:utf8");
+ok((print $io chr(256)), "print chr(256)");
+undef $io;
+
+$io = IO::File->new;
+ok($io->open("io_utf8", "<:utf8"), "open <:utf8");
+is(ord(<$io>), 256, "readline chr(256)");
+undef $io;
+
+END {
+ 1 while unlink "io_utf8";
+}