|
Packit |
800465 |
NAME
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All - IO::All to Larry Wall!
|
|
Packit |
800465 |
|
|
Packit |
800465 |
VERSION
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This document describes IO::All version 0.87.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
SYNOPSIS
|
|
Packit |
800465 |
|
|
Packit |
800465 |
First, some safe examples:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Some of the many ways to read a whole file into a scalar
|
|
Packit |
800465 |
$contents = io->file('file.txt')->slurp; # Read an entire file
|
|
Packit |
800465 |
@files = io->dir('lib')->all; # Get a list of files
|
|
Packit |
800465 |
$tail = io->pipe('-| tail app.log'); # Open a pipe to a command
|
|
Packit |
800465 |
$line = $tail->getline; # Read from the pipe
|
|
Packit |
800465 |
|
|
Packit |
800465 |
That said, there are a lot more things that are very convenient and
|
|
Packit |
800465 |
will help you write code very quickly, though they should be used
|
|
Packit |
800465 |
judiciously:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All; # Let the madness begin...
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Some of the many ways to read a whole file into a scalar
|
|
Packit |
800465 |
io('file.txt') > $contents; # Overloaded "arrow"
|
|
Packit |
800465 |
$contents < io 'file.txt'; # Flipped but same operation
|
|
Packit |
800465 |
$io = io 'file.txt'; # Create a new IO::All object
|
|
Packit |
800465 |
$contents = $$io; # Overloaded scalar dereference
|
|
Packit |
800465 |
$contents = $io->all; # A method to read everything
|
|
Packit |
800465 |
$contents = $io->slurp; # Another method for that
|
|
Packit |
800465 |
$contents = join '', $io->getlines; # Join the separate lines
|
|
Packit |
800465 |
$contents = join '', map "$_\n", @$io; # Same. Overloaded array deref
|
|
Packit |
800465 |
$io->tie; # Tie the object as a handle
|
|
Packit |
800465 |
$contents = join '', <$io>; # And use it in builtins
|
|
Packit |
800465 |
# and the list goes on ...
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Other file operations:
|
|
Packit |
800465 |
@lines = io('file.txt')->slurp; # List context slurp
|
|
Packit |
800465 |
$content > io('file.txt'); # Print to a file
|
|
Packit |
800465 |
io('file.txt')->print($content, $more); # (ditto)
|
|
Packit |
800465 |
$content >> io('file.txt'); # Append to a file
|
|
Packit |
800465 |
io('file.txt')->append($content); # (ditto)
|
|
Packit |
800465 |
$content << $io; # Append to a string
|
|
Packit |
800465 |
io('copy.txt') < io('file.txt'); $ Copy a file
|
|
Packit |
800465 |
io('file.txt') > io('copy.txt'); # Invokes File::Copy
|
|
Packit |
800465 |
io('more.txt') >> io('all.txt'); # Add on to a file
|
|
Packit |
800465 |
io('dir/') < io('file.txt'); $ Copy a file to a directory
|
|
Packit |
800465 |
io('file.txt') > io('dir/'); # Invokes File::Copy
|
|
Packit |
800465 |
io('more.txt') >> io('dir/'); # Add on to a file in the dir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# UTF-8 Support
|
|
Packit |
800465 |
$contents = io('file.txt')->utf8->all; # Turn on utf8
|
|
Packit |
800465 |
use IO::All -utf8; # Turn on utf8 for all io
|
|
Packit |
800465 |
$contents = io('file.txt')->all; # by default in this package.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# General Encoding Support
|
|
Packit |
800465 |
$contents = io('file.txt')->encoding('big5')->all;
|
|
Packit |
800465 |
use IO::All -encoding => 'big5'; # Turn on big5 for all io
|
|
Packit |
800465 |
$contents = io('file.txt')->all; # by default in this package.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print the path name of a file:
|
|
Packit |
800465 |
print $io->name; # The direct method
|
|
Packit |
800465 |
print "$io"; # Object stringifies to name
|
|
Packit |
800465 |
print $io; # Quotes not needed here
|
|
Packit |
800465 |
print $io->filename; # The file portion only
|
|
Packit |
800465 |
$io->os('win32'); # change the object to be a
|
|
Packit |
800465 |
# win32 path
|
|
Packit |
800465 |
print $io->ext; # The file extension only
|
|
Packit |
800465 |
print $io->mimetype; # The mimetype, requires a
|
|
Packit |
800465 |
# working File::MimeType
|
|
Packit |
800465 |
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Read all the files/directories in a directory:
|
|
Packit |
800465 |
$io = io('my/directory/'); # Create new directory object
|
|
Packit |
800465 |
@contents = $io->all; # Get all contents of dir
|
|
Packit |
800465 |
@contents = @$io; # Directory as an array
|
|
Packit |
800465 |
@contents = values %$io; # Directory as a hash
|
|
Packit |
800465 |
push @contents, $subdir # One at a time
|
|
Packit |
800465 |
while $subdir = $io->next;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print the name and file type for all the contents above:
|
|
Packit |
800465 |
print "$_ is a " . $_->type . "\n" # Each element of @contents
|
|
Packit |
800465 |
for @contents; # is an IO::All object!!
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print first line of each file:
|
|
Packit |
800465 |
print $_->getline # getline gets one line
|
|
Packit |
800465 |
for io('dir')->all_files; # Files only
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print names of all files/dirs three directories deep:
|
|
Packit |
800465 |
print "$_\n" for $io->all(3); # Pass in the depth. Default=1
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print names of all files/dirs recursively:
|
|
Packit |
800465 |
print "$_\n" for $io->all(0); # Zero means all the way down
|
|
Packit |
800465 |
print "$_\n" for $io->All; # Capitalized shortcut
|
|
Packit |
800465 |
print "$_\n" for $io->deep->all; # Another way
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# There are some special file names:
|
|
Packit |
800465 |
print io('-'); # Print STDIN to STDOUT
|
|
Packit |
800465 |
io('-') > io('-'); # Do it again
|
|
Packit |
800465 |
io('-') < io('-'); # Same. Context sensitive.
|
|
Packit |
800465 |
"Bad puppy" > io('='); # Message to STDERR
|
|
Packit |
800465 |
$string_file = io('$'); # Create string based filehandle
|
|
Packit |
800465 |
$temp_file = io('?'); # Create a temporary file
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Socket operations:
|
|
Packit |
800465 |
$server = io('localhost:5555')->fork; # Create a daemon socket
|
|
Packit |
800465 |
$connection = $server->accept; # Get a connection socket
|
|
Packit |
800465 |
$input < $connection; # Get some data from it
|
|
Packit |
800465 |
"Thank you!" > $connection; # Thank the caller
|
|
Packit |
800465 |
$connection->close; # Hang up
|
|
Packit |
800465 |
io(':6666')->accept->slurp > io->devnull; # Take a complaint and file it
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# DBM database operations:
|
|
Packit |
800465 |
$dbm = io 'my/database'; # Create a database object
|
|
Packit |
800465 |
print $dbm->{grocery_list}; # Hash context makes it a DBM
|
|
Packit |
800465 |
$dbm->{todo} = $new_list; # Write to database
|
|
Packit |
800465 |
$dbm->dbm('GDBM_file'); # Demand specific DBM
|
|
Packit |
800465 |
io('mydb')->mldbm->{env} = \%ENV; # MLDBM support
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Tie::File support:
|
|
Packit |
800465 |
$io = io 'file.txt';
|
|
Packit |
800465 |
$io->[42] = 'Line Forty Three'; # Change a line
|
|
Packit |
800465 |
print $io->[@$io / 2]; # Print middle line
|
|
Packit |
800465 |
@$io = reverse @$io; # Reverse lines in a file
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Stat functions:
|
|
Packit |
800465 |
printf "%s %s %s\n", # Print name, uid and size of
|
|
Packit |
800465 |
$_->name, $_->uid, $_->size # contents of current directory
|
|
Packit |
800465 |
for io('.')->all;
|
|
Packit |
800465 |
print "$_\n" for sort # Use mtime method to sort all
|
|
Packit |
800465 |
{$b->mtime <=> $a->mtime} # files under current directory
|
|
Packit |
800465 |
io('.')->All_Files; # by recent modification time.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# File::Spec support:
|
|
Packit |
800465 |
$contents < io->catfile(qw(dir file.txt)); # Portable IO operation
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Miscellaneous:
|
|
Packit |
800465 |
@lines = io('file.txt')->chomp->slurp; # Chomp as you slurp
|
|
Packit |
800465 |
@chunks =
|
|
Packit |
800465 |
io('file.txt')->separator('xxx')->slurp; # Use alternnate record sep
|
|
Packit |
800465 |
$binary = io('file.bin')->binary->all; # Read a binary file
|
|
Packit |
800465 |
io('a-symlink')->readlink->slurp; # Readlink returns an object
|
|
Packit |
800465 |
print io('foo')->absolute->pathname; # Print absolute path of foo
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# IO::All External Plugin Methods
|
|
Packit |
800465 |
io("myfile") > io->("ftp://store.org"); # Upload a file using ftp
|
|
Packit |
800465 |
$html < io->http("www.google.com"); # Grab a web page
|
|
Packit |
800465 |
io('mailto:worst@enemy.net')->print($spam); # Email a "friend"
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# This is just the beginning, read on...
|
|
Packit |
800465 |
|
|
Packit |
800465 |
DESCRIPTION
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All combines all of the best Perl IO modules into a single nifty
|
|
Packit |
800465 |
object oriented interface to greatly simplify your everyday Perl IO
|
|
Packit |
800465 |
idioms. It exports a single function called io, which returns a new
|
|
Packit |
800465 |
IO::All object. And that object can do it all!
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The IO::All object is a proxy for IO::File, IO::Dir, IO::Socket,
|
|
Packit |
800465 |
Tie::File, File::Spec, File::Path, File::MimeInfo and
|
|
Packit |
800465 |
File::ReadBackwards; as well as all the DBM and MLDBM modules. You can
|
|
Packit |
800465 |
use most of the methods found in these classes and in IO::Handle (which
|
|
Packit |
800465 |
they inherit from). IO::All adds dozens of other helpful idiomatic
|
|
Packit |
800465 |
methods including file stat and manipulation functions.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All is pluggable, and modules like IO::All::LWP and IO::All::Mailto
|
|
Packit |
800465 |
add even more functionality. Optionally, every IO::All object can be
|
|
Packit |
800465 |
tied to itself. This means that you can use most perl IO builtins on
|
|
Packit |
800465 |
it: readline, <>, getc, print, printf, syswrite, sysread, close.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The distinguishing magic of IO::All is that it will automatically open
|
|
Packit |
800465 |
(and close) files, directories, sockets and other IO things for you.
|
|
Packit |
800465 |
You never need to specify the mode (<, >>, etc), since it is determined
|
|
Packit |
800465 |
by the usage context. That means you can replace this:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
open STUFF, '<', './mystuff'
|
|
Packit |
800465 |
or die "Can't open './mystuff' for input:\n$!";
|
|
Packit |
800465 |
local $/;
|
|
Packit |
800465 |
my $stuff = <STUFF>;
|
|
Packit |
800465 |
close STUFF;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
with this:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $stuff < io './mystuff';
|
|
Packit |
800465 |
|
|
Packit |
800465 |
And that is a good thing!
|
|
Packit |
800465 |
|
|
Packit |
800465 |
USAGE
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Normally just say:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
and IO::All will export a single function called io, which constructs
|
|
Packit |
800465 |
all IO objects.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Note on io
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The io function is a magic constructor. It is easy to use and will
|
|
Packit |
800465 |
usually do the right thing, but can also blow up easily.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
It takes a single optional argument and determines what type of IO::All
|
|
Packit |
800465 |
subclass object to return. With no arguments it returns an IO::All
|
|
Packit |
800465 |
object, which has no I/O methods, but has methods to construct subclass
|
|
Packit |
800465 |
objects like IO::All::File.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
In other words, these 2 statements are usually the same:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$content = io('file.txt')->all;
|
|
Packit |
800465 |
$content = io->file('file.txt')->all;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Use the first form when you are demonstrating your Perl virtues of
|
|
Packit |
800465 |
laziness and impatience, and use the second form when your job is on
|
|
Packit |
800465 |
the line.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
METHOD ROLE CALL
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Here is an alphabetical list of all the public methods that you can
|
|
Packit |
800465 |
call on an IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
"abs2rel", "absolute", "accept", "All", "all", "All_Dirs", "all_dirs",
|
|
Packit |
800465 |
"All_Files", "all_files", "All_Links", "all_links", "append",
|
|
Packit |
800465 |
"appendf", "appendln", "assert", "atime", "autoclose", "autoflush",
|
|
Packit |
800465 |
"backwards", "bcc", "binary", "binmode", "blksize", "blocks",
|
|
Packit |
800465 |
"block_size", "buffer", "canonpath", "case_tolerant", "catdir",
|
|
Packit |
800465 |
"catfile", "catpath", "cc", "chdir", "chomp", "clear", "close",
|
|
Packit |
800465 |
"confess", "content", "copy", "ctime", "curdir", "dbm", "deep",
|
|
Packit |
800465 |
"device", "device_id", "devnull", "dir", "domain", "empty", "ext",
|
|
Packit |
800465 |
"encoding", "eof", "errors", "file", "filename", "fileno", "filepath",
|
|
Packit |
800465 |
"filter", "fork", "from", "ftp", "get", "getc", "getline", "getlines",
|
|
Packit |
800465 |
"gid", "glob", "handle", "head", "http", "https", "inode", "io_handle",
|
|
Packit |
800465 |
"is_absolute", "is_dir", "is_dbm", "is_executable", "is_file",
|
|
Packit |
800465 |
"is_link", "is_mldbm", "is_open", "is_pipe", "is_readable",
|
|
Packit |
800465 |
"is_socket", "is_stdio", "is_string", "is_temp", "is_writable", "join",
|
|
Packit |
800465 |
"length", "link", "lock", "mailer", "mailto", "mimetype", "mkdir",
|
|
Packit |
800465 |
"mkpath", "mldbm", "mode", "modes", "mtime", "name", "new", "next",
|
|
Packit |
800465 |
"nlink", "open", "os" "password", "path", "pathname", "perms", "pipe",
|
|
Packit |
800465 |
"port", "print", "printf", "println", "put", "rdonly", "rdwr", "read",
|
|
Packit |
800465 |
"readdir", "readlink", "recv", "rel2abs", "relative", "rename",
|
|
Packit |
800465 |
"request", "response", "rmdir", "rmtree", "rootdir", "scalar", "seek",
|
|
Packit |
800465 |
"send", "separator", "shutdown", "size", "slurp", "socket", "sort",
|
|
Packit |
800465 |
"splitdir", "splitpath", "stat", "stdio", "stderr", "stdin", "stdout",
|
|
Packit |
800465 |
"string", "string_ref", "subject", "sysread", "syswrite", "tail",
|
|
Packit |
800465 |
"tell", "temp", "tie", "tmpdir", "to", "touch", "truncate", "type",
|
|
Packit |
800465 |
"user", "uid", "unlink", "unlock", "updir", "uri", "utf8", "utime" and
|
|
Packit |
800465 |
"write".
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Each method is documented further below.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
OPERATOR OVERLOADING
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All objects overload a small set of Perl operators to great effect.
|
|
Packit |
800465 |
The overloads are limited to <, <<, >, >>, dereferencing operations,
|
|
Packit |
800465 |
and stringification.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Even though relatively few operations are overloaded, there is actually
|
|
Packit |
800465 |
a huge matrix of possibilities for magic. That's because the
|
|
Packit |
800465 |
overloading is sensitive to the types, position and context of the
|
|
Packit |
800465 |
arguments, and an IO::All object can be one of many types.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The most important overload to become familiar with is stringification.
|
|
Packit |
800465 |
IO::All objects stringify to their file or directory name. Here we
|
|
Packit |
800465 |
print the contents of the current directory:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
perl -MIO::All -le 'print for io(".")->all'
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is the same as:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
perl -MIO::All -le 'print $_->name for io(".")->all'
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Stringification is important because it allows IO::All operations to
|
|
Packit |
800465 |
return objects when they might otherwise return file names. Then the
|
|
Packit |
800465 |
recipient can use the result either as an object or a string.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
> and < move data between objects in the direction pointed to by the
|
|
Packit |
800465 |
operator.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$content1 < io('file1');
|
|
Packit |
800465 |
$content1 > io('file2');
|
|
Packit |
800465 |
io('file2') > $content3;
|
|
Packit |
800465 |
io('file3') < $content3;
|
|
Packit |
800465 |
io('file3') > io('file4');
|
|
Packit |
800465 |
io('file5') < io('file4');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
>> and << do the same thing except the recipient string or file is
|
|
Packit |
800465 |
appended to.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
An IO::All file used as an array reference becomes tied using
|
|
Packit |
800465 |
Tie::File:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$file = io "file";
|
|
Packit |
800465 |
# Print last line of file
|
|
Packit |
800465 |
print $file->[-1];
|
|
Packit |
800465 |
# Insert new line in middle of file
|
|
Packit |
800465 |
$file->[$#$file / 2] = 'New line';
|
|
Packit |
800465 |
|
|
Packit |
800465 |
An IO::All file used as a hash reference becomes tied to a DBM class:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('mydbm')->{ingy} = 'YAML';
|
|
Packit |
800465 |
|
|
Packit |
800465 |
An IO::All directory used as an array reference, will expose each file
|
|
Packit |
800465 |
or subdirectory as an element of the array.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
print "$_\n" for @{io 'dir'};
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All directories used as hash references have file names as keys,
|
|
Packit |
800465 |
and IO::All objects as values:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
print io('dir')->{'foo.txt'}->slurp;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Files used as scalar references get slurped:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
print ${io('dir')->{'foo.txt'}};
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Not all combinations of operations and object types are supported. Some
|
|
Packit |
800465 |
just haven't been added yet, and some just don't make sense. If you use
|
|
Packit |
800465 |
an invalid combination, an error will be thrown.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
COOKBOOK
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This section describes some various things that you can easily cook up
|
|
Packit |
800465 |
with IO::All.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
File Locking
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All makes it very easy to lock files. Just use the lock method.
|
|
Packit |
800465 |
Here's a standalone program that demonstrates locking for both write
|
|
Packit |
800465 |
and read:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
my $io1 = io('myfile')->lock;
|
|
Packit |
800465 |
$io1->println('line 1');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
fork or do {
|
|
Packit |
800465 |
my $io2 = io('myfile')->lock;
|
|
Packit |
800465 |
print $io2->slurp;
|
|
Packit |
800465 |
exit;
|
|
Packit |
800465 |
};
|
|
Packit |
800465 |
|
|
Packit |
800465 |
sleep 1;
|
|
Packit |
800465 |
$io1->println('line 2');
|
|
Packit |
800465 |
$io1->println('line 3');
|
|
Packit |
800465 |
$io1->unlock;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
There are a lot of subtle things going on here. An exclusive lock is
|
|
Packit |
800465 |
issued for $io1 on the first println. That's because the file isn't
|
|
Packit |
800465 |
actually opened until the first IO operation.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
When the child process tries to read the file using $io2, there is a
|
|
Packit |
800465 |
shared lock put on it. Since $io1 has the exclusive lock, the slurp
|
|
Packit |
800465 |
blocks.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The parent process sleeps just to make sure the child process gets a
|
|
Packit |
800465 |
chance. The parent needs to call unlock or close to release the lock.
|
|
Packit |
800465 |
If all goes well the child will print 3 lines.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
In-place Editing
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Because an IO::All object can be used as an array reference, operations
|
|
Packit |
800465 |
on arrays are supported transparently (using Tie::File) so a file can
|
|
Packit |
800465 |
be modified in the same way you would modify an array.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
> cat > x.txt
|
|
Packit |
800465 |
The sexy saxophone,
|
|
Packit |
800465 |
|
|
Packit |
800465 |
got the axe.
|
|
Packit |
800465 |
^d
|
|
Packit |
800465 |
|
|
Packit |
800465 |
> perl -MIO::All -e 'map { s/x/X/g; $_ } @{ io(shift) }' x.txt
|
|
Packit |
800465 |
> cat x.txt
|
|
Packit |
800465 |
The seXy saXophone,
|
|
Packit |
800465 |
|
|
Packit |
800465 |
got the aXe.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This one liner uses shift() to grab the file from STDIN and create an io
|
|
Packit |
800465 |
object that is dereferenced using @{ } and fed to map() like any perl array
|
|
Packit |
800465 |
reference.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Round Robin
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This simple example will read lines from a file forever. When the last
|
|
Packit |
800465 |
line is read, it will reopen the file and read the first one again.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io 'file1.txt';
|
|
Packit |
800465 |
$io->autoclose(1);
|
|
Packit |
800465 |
while (my $line = $io->getline || $io->getline) {
|
|
Packit |
800465 |
print $line;
|
|
Packit |
800465 |
}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Reading Backwards
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If you call the backwards method on an IO::All object, the getline and
|
|
Packit |
800465 |
getlines will work in reverse. They will read the lines in the file
|
|
Packit |
800465 |
from the end to the beginning.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my @reversed;
|
|
Packit |
800465 |
my $io = io('file1.txt');
|
|
Packit |
800465 |
$io->backwards;
|
|
Packit |
800465 |
while (my $line = $io->getline) {
|
|
Packit |
800465 |
push @reversed, $line;
|
|
Packit |
800465 |
}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
or more simply:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my @reversed = io('file1.txt')->backwards->getlines;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The backwards method returns the IO::All object so that you can chain
|
|
Packit |
800465 |
the calls.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
NOTE: This operation requires that you have the File::ReadBackwards
|
|
Packit |
800465 |
module installed.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Client/Server Sockets
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All makes it really easy to write a forking socket server and a
|
|
Packit |
800465 |
client to talk to it.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
In this example, a server will return 3 lines of text, to every client
|
|
Packit |
800465 |
that calls it. Here is the server code:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $socket = io(':12345')->fork->accept;
|
|
Packit |
800465 |
$socket->print($_) while <DATA>;
|
|
Packit |
800465 |
$socket->close;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
__DATA__
|
|
Packit |
800465 |
On your mark,
|
|
Packit |
800465 |
Get set,
|
|
Packit |
800465 |
Go!
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Here is the client code:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('localhost:12345');
|
|
Packit |
800465 |
print while $_ = $io->getline;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
You can run the server once, and then run the client repeatedly (in
|
|
Packit |
800465 |
another terminal window). It should print the 3 data lines each time.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Note that it is important to close the socket if the server is forking,
|
|
Packit |
800465 |
or else the socket won't go out of scope and close.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
A Tiny Web Server
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Here is how you could write a simplistic web server that works with
|
|
Packit |
800465 |
static and dynamic pages:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 ? "./$1 |" : $1) if /^GET \/(.*) / })'
|
|
Packit |
800465 |
|
|
Packit |
800465 |
There is are a lot of subtle things going on here. First we accept a
|
|
Packit |
800465 |
socket and fork the server. Then we overload the new socket as a code
|
|
Packit |
800465 |
ref. This code ref takes one argument, another code ref, which is used
|
|
Packit |
800465 |
as a callback.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The callback is called once for every line read on the socket. The line
|
|
Packit |
800465 |
is put into $_ and the socket itself is passed in to the callback.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Our callback is scanning the line in $_ for an HTTP GET request. If one
|
|
Packit |
800465 |
is found it parses the file name into $1. Then we use $1 to create an
|
|
Packit |
800465 |
new IO::All file object... with a twist. If the file is executable
|
|
Packit |
800465 |
(-x), then we create a piped command as our IO::All object. This
|
|
Packit |
800465 |
somewhat approximates CGI support.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Whatever the resulting object is, we direct the contents back at our
|
|
Packit |
800465 |
socket which is in $_[0]. Pretty simple, eh?
|
|
Packit |
800465 |
|
|
Packit |
800465 |
DBM Files
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All file objects used as a hash reference, treat the file as a DBM
|
|
Packit |
800465 |
tied to a hash. Here I write my DB record to STDERR:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io("names.db")->{ingy} > io('=');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Since their are several DBM formats available in Perl, IO::All picks
|
|
Packit |
800465 |
the first one of these that is installed on your system:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
DB_File GDBM_File NDBM_File ODBM_File SDBM_File
|
|
Packit |
800465 |
|
|
Packit |
800465 |
You can override which DBM you want for each IO::All object:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my @keys = keys %{io('mydbm')->dbm('SDBM_File')};
|
|
Packit |
800465 |
|
|
Packit |
800465 |
File Subclassing
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Subclassing is easy with IO::All. Just create a new module and use
|
|
Packit |
800465 |
IO::All as the base class, like this:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
package NewModule;
|
|
Packit |
800465 |
use IO::All -base;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
You need to do it this way so that IO::All will export the io function.
|
|
Packit |
800465 |
Here is a simple recipe for subclassing:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::Dumper inherits everything from IO::All and adds an extra method
|
|
Packit |
800465 |
called dump, which will dump a data structure to the file we specify in
|
|
Packit |
800465 |
the io function. Since it needs Data::Dumper to do the dumping, we
|
|
Packit |
800465 |
override the open method to require Data::Dumper and then pass control
|
|
Packit |
800465 |
to the real open.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
First the code using the module:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::Dumper;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('./mydump')->dump($hash);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
And next the IO::Dumper module itself:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
package IO::Dumper;
|
|
Packit |
800465 |
use IO::All -base;
|
|
Packit |
800465 |
use Data::Dumper;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
sub dump {
|
|
Packit |
800465 |
my $self = shift;
|
|
Packit |
800465 |
Dumper(@_) > $self;
|
|
Packit |
800465 |
}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
1;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Inline Subclassing
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This recipe does the same thing as the previous one, but without
|
|
Packit |
800465 |
needing to write a separate module. The only real difference is the
|
|
Packit |
800465 |
first line. Since you don't "use" IO::Dumper, you need to still call
|
|
Packit |
800465 |
its import method manually.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::Dumper->import;
|
|
Packit |
800465 |
io('./mydump')->dump($hash);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
package IO::Dumper;
|
|
Packit |
800465 |
use IO::All -base;
|
|
Packit |
800465 |
use Data::Dumper;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
sub dump {
|
|
Packit |
800465 |
my $self = shift;
|
|
Packit |
800465 |
Dumper(@_) > $self;
|
|
Packit |
800465 |
}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
THE IO::ALL METHODS
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This section gives a full description of all of the methods that you
|
|
Packit |
800465 |
can call on IO::All objects. The methods have been grouped into
|
|
Packit |
800465 |
subsections based on object construction, option settings,
|
|
Packit |
800465 |
configuration, action methods and support for specific modules.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Object Construction and Initialization Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
new
|
|
Packit |
800465 |
|
|
Packit |
800465 |
There are three ways to create a new IO::All object. The first is
|
|
Packit |
800465 |
with the special function io which really just calls IO::All->new.
|
|
Packit |
800465 |
The second is by calling new as a class method. The third is calling
|
|
Packit |
800465 |
new as an object instance method. In this final case, the new objects
|
|
Packit |
800465 |
attributes are copied from the instance object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io(file-descriptor);
|
|
Packit |
800465 |
IO::All->new(file-descriptor);
|
|
Packit |
800465 |
$io->new(file-descriptor);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All three forms take a single argument, a file descriptor. A file
|
|
Packit |
800465 |
descriptor can be any of the following:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
- A file name
|
|
Packit |
800465 |
- A file handle
|
|
Packit |
800465 |
- A directory name
|
|
Packit |
800465 |
- A directory handle
|
|
Packit |
800465 |
- A typeglob reference
|
|
Packit |
800465 |
- A piped shell command. eg '| ls -al'
|
|
Packit |
800465 |
- A socket domain/port. eg 'perl.com:5678'
|
|
Packit |
800465 |
- '-' means STDIN or STDOUT (depending on usage)
|
|
Packit |
800465 |
- '=' means STDERR
|
|
Packit |
800465 |
- '$' means an in memory filehandle object
|
|
Packit |
800465 |
- '?' means a temporary file
|
|
Packit |
800465 |
- A URI including: http, https, ftp and mailto
|
|
Packit |
800465 |
- An IO::All object
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If you provide an IO::All object, you will simply get that same
|
|
Packit |
800465 |
object returned from the constructor.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If no file descriptor is provided, an object will still be created,
|
|
Packit |
800465 |
but it must be defined by one of the following methods before it can
|
|
Packit |
800465 |
be used for I/O:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
file
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->file("path/to/my/file.txt");
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Using the file method sets the type of the object to file and sets
|
|
Packit |
800465 |
the pathname of the file if provided.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
It might be important to use this method if you had a file whose name
|
|
Packit |
800465 |
was '- ', or if the name might otherwise be confused with a directory
|
|
Packit |
800465 |
or a socket. In this case, either of these statements would work the
|
|
Packit |
800465 |
same:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $file = io('-')->file;
|
|
Packit |
800465 |
my $file = io->file('-');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
dir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->dir($dir_name);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object be of type directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
socket
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->socket("${domain}:${port}");
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object be of type socket.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
link
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->link($link_name);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object be of type link.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
pipe
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->pipe($pipe_command);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object be of type pipe. The following three statements are
|
|
Packit |
800465 |
equivalent:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('ls -l |');
|
|
Packit |
800465 |
my $io = io('ls -l')->pipe;
|
|
Packit |
800465 |
my $io = io->pipe('ls -l');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
dbm
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This method takes the names of zero or more DBM modules. The first
|
|
Packit |
800465 |
one that is available is used to process the dbm file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('mydbm')->dbm('NDBM_File', 'SDBM_File')->{author} = 'ingy';
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If no module names are provided, the first available of the following
|
|
Packit |
800465 |
is used:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
DB_File GDBM_File NDBM_File ODBM_File SDBM_File
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mldbm
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Similar to the dbm method, except create a Multi Level DBM object
|
|
Packit |
800465 |
using the MLDBM module.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This method takes the names of zero or more DBM modules and an
|
|
Packit |
800465 |
optional serialization module. The first DBM module that is available
|
|
Packit |
800465 |
is used to process the MLDBM file. The serialization module can be
|
|
Packit |
800465 |
Data::Dumper, Storable or FreezeThaw.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('mymldbm')->mldbm('GDBM_File', 'Storable')->{author} =
|
|
Packit |
800465 |
{nickname => 'ingy'};
|
|
Packit |
800465 |
|
|
Packit |
800465 |
string
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object be an in memory filehandle. These are equivalent:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('$');
|
|
Packit |
800465 |
my $io = io->string;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
temp
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent a temporary file. It will automatically be
|
|
Packit |
800465 |
open for both read and write.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
stdio
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent either STDIN or STDOUT depending on how it
|
|
Packit |
800465 |
is used subsequently. These are equivalent:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('-');
|
|
Packit |
800465 |
my $io = io->stdin;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
stdin
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent STDIN.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
stdout
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent STDOUT.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
stderr
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent STDERR.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
handle
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->handle($io_handle);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Forces the object to be created from an pre-existing IO handle. You
|
|
Packit |
800465 |
can chain calls together to indicate the type of handle:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $file_object = io->file->handle($file_handle);
|
|
Packit |
800465 |
my $dir_object = io->dir->handle($dir_handle);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
http
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent an HTTP URI. Requires IO-All-LWP.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
https
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent an HTTPS URI. Requires IO-All-LWP.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
ftp
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent an FTP URI. Requires IO-All-LWP.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mailto
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Make the object represent a mailto: URI. Requires IO-All-Mailto.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If you need to use the same options to create a lot of objects, and
|
|
Packit |
800465 |
don't want to duplicate the code, just create a dummy object with the
|
|
Packit |
800465 |
options you want, and use that object to spawn other objects.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $lt = io->lock->tie;
|
|
Packit |
800465 |
...
|
|
Packit |
800465 |
my $io1 = $lt->new('file1');
|
|
Packit |
800465 |
my $io2 = $lt->new('file2');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Since the new method copies attributes from the calling object, both
|
|
Packit |
800465 |
$io1 and $io2 will be locked and tied.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Option Setting Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The following methods don't do any actual IO, but they specify options
|
|
Packit |
800465 |
about how the IO should be done.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Each option can take a single argument of 0 or 1. If no argument is
|
|
Packit |
800465 |
given, the value 1 is assumed. Passing 0 turns the option off.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All of these options return the object reference that was used to
|
|
Packit |
800465 |
invoke them. This is so that the option methods can be chained
|
|
Packit |
800465 |
together. For example:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('path/file')->tie->assert->chomp->lock;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
absolute
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates that the pathname for the object should be made absolute.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Print the full path of the current working directory
|
|
Packit |
800465 |
# (like pwd).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
print io->curdir->absolute;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
assert
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This method ensures that the path for a file or directory actually
|
|
Packit |
800465 |
exists before the file is open. If the path does not exist, it is
|
|
Packit |
800465 |
created.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For example, here is a program called "create-cat-to" that outputs to
|
|
Packit |
800465 |
a file that it creates.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
#!/usr/bin/perl
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# create-cat-to.pl
|
|
Packit |
800465 |
# cat to a file that can be created.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use strict;
|
|
Packit |
800465 |
use warnings;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
use IO::All;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $filename = shift(@ARGV);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
# Create a file called $filename, including all leading components.
|
|
Packit |
800465 |
io('-') > io->file($filename)->assert;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Here's an example use of it:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$ ls -l
|
|
Packit |
800465 |
total 0
|
|
Packit |
800465 |
$ echo "Hello World" | create-cat-to one/two/three/four.txt
|
|
Packit |
800465 |
$ ls -l
|
|
Packit |
800465 |
total 4
|
|
Packit |
800465 |
drwxr-xr-x 3 shlomif shlomif 4096 2010-10-14 18:03 one/
|
|
Packit |
800465 |
$ cat one/two/three/four.txt
|
|
Packit |
800465 |
Hello World
|
|
Packit |
800465 |
$
|
|
Packit |
800465 |
|
|
Packit |
800465 |
autoclose
|
|
Packit |
800465 |
|
|
Packit |
800465 |
By default, IO::All will close an object opened for input when EOF is
|
|
Packit |
800465 |
reached. By closing the handle early, one can immediately do other
|
|
Packit |
800465 |
operations on the object without first having to close it.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This option is on by default, so if you don't want this behaviour,
|
|
Packit |
800465 |
say so like this:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$io->autoclose(0);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The object will then be closed when $io goes out of scope, or you
|
|
Packit |
800465 |
manually call $io->close.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
autoflush
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::autoflush
|
|
Packit |
800465 |
|
|
Packit |
800465 |
backwards
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Sets the object to 'backwards' mode. All subsequent getline
|
|
Packit |
800465 |
operations will read backwards from the end of the file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Requires the File::ReadBackwards CPAN module.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
binary
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Adds :raw to the list of PerlIO layers applied after open, and
|
|
Packit |
800465 |
applies it immediately on an open handle.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
chdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
chdir() to the pathname of a directory object. When object goes out
|
|
Packit |
800465 |
of scope, chdir back to starting directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
chomp
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates that all operations that read lines should chomp the lines.
|
|
Packit |
800465 |
If the separator method has been called, chomp will remove that value
|
|
Packit |
800465 |
from the end of each record.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Note that chomp may cause the following idiom to halt prematurely
|
|
Packit |
800465 |
(e.g., if separator is \n (the default) and chomp is in effect, then
|
|
Packit |
800465 |
this command will stop reading at the first blank line):
|
|
Packit |
800465 |
|
|
Packit |
800465 |
while ( my $line = $io->getline ) {...}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Try the following instead:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
while ( defined(my $line = $io->getline) ) {...}
|
|
Packit |
800465 |
|
|
Packit |
800465 |
confess
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Errors should be reported with the very detailed Carp::confess
|
|
Packit |
800465 |
function.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
deep
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates that calls to the all family of methods should search
|
|
Packit |
800465 |
directories as deep as possible.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
fork
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates that the process should automatically be forked inside the
|
|
Packit |
800465 |
accept socket method.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
lock
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicate that operations on an object should be locked using flock.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rdonly
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This option indicates that certain operations like DBM and Tie::File
|
|
Packit |
800465 |
access should be done in read-only mode.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rdwr
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This option indicates that DBM and MLDBM files should be opened in
|
|
Packit |
800465 |
read/write mode.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
relative
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates that the pathname for the object should be made relative.
|
|
Packit |
800465 |
If passed an argument, path will be made relative to passed argument.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
sort
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates whether objects returned from one of the all methods will
|
|
Packit |
800465 |
be in sorted order by name. True by default.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
tie
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicate that the object should be tied to itself, thus allowing it
|
|
Packit |
800465 |
to be used as a filehandle in any of Perl's builtin IO operations.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('foo')->tie;
|
|
Packit |
800465 |
@lines = <$io>;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
utf8
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Adds :encoding(UTF-8) to the list of PerlIO layers applied after
|
|
Packit |
800465 |
open, and applies it immediately on an open handle.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Configuration Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The following methods don't do any actual I/O, but they set specific
|
|
Packit |
800465 |
values to configure the IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If these methods are passed no argument, they will return their current
|
|
Packit |
800465 |
value. If arguments are passed they will be used to set the current
|
|
Packit |
800465 |
value, and the object reference will be returned for potential method
|
|
Packit |
800465 |
chaining.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
bcc
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the Bcc field for a mailto object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
binmode
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Adds the specified layer to the list of PerlIO layers applied after
|
|
Packit |
800465 |
open, and applies it immediately on an open handle. Does a bare
|
|
Packit |
800465 |
binmode when called without argument.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
block_size
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The default length to be used for read and sysread calls. Defaults to
|
|
Packit |
800465 |
1024.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
buffer
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a reference to the internal buffer, which is a scalar. You
|
|
Packit |
800465 |
can use this method to set the buffer to a scalar of your choice.
|
|
Packit |
800465 |
(You can just pass in the scalar, rather than a reference to it.)
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This is the buffer that read and write will use by default.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
You can easily have IO::All objects use the same buffer:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $input = io('abc');
|
|
Packit |
800465 |
my $output = io('xyz');
|
|
Packit |
800465 |
my $buffer;
|
|
Packit |
800465 |
$output->buffer($input->buffer($buffer));
|
|
Packit |
800465 |
$output->write while $input->read;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
cc
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the Cc field for a mailto object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
content
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Get or set the content for an LWP operation manually.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
domain
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the domain name or ip address that a socket should use.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
encoding
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Adds the specified encoding to the list of PerlIO layers applied
|
|
Packit |
800465 |
after open, and applies it immediately on an open handle. Requires an
|
|
Packit |
800465 |
argument.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
errors
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Use this to set a subroutine reference that gets called when an
|
|
Packit |
800465 |
internal error is thrown.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
filter
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Use this to set a subroutine reference that will be used to grep
|
|
Packit |
800465 |
which objects get returned on a call to one of the all methods. For
|
|
Packit |
800465 |
example:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my @odd = io->curdir->filter(sub {$_->size % 2})->All_Files;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
@odd will contain all the files under the current directory whose
|
|
Packit |
800465 |
size is an odd number of bytes.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
from
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicate the sender for a mailto object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mailer
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the mailer program for a mailto transaction. Defaults to
|
|
Packit |
800465 |
'sendmail'.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mode
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the mode for which the file should be opened. Examples:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$io->mode('>>')->open;
|
|
Packit |
800465 |
$io->mode(O_RDONLY);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $log_appender = io->file('/var/log/my-application.log')
|
|
Packit |
800465 |
->mode('>>')->open();
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$log_appender->print("Stardate 5987.6: Mission accomplished.");
|
|
Packit |
800465 |
|
|
Packit |
800465 |
name
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set or get the name of the file or directory represented by the
|
|
Packit |
800465 |
IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
password
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the password for an LWP transaction.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
perms
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Sets the permissions to be used if the file/directory needs to be
|
|
Packit |
800465 |
created.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
port
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the port number that a socket should use.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
request
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Manually specify the request object for an LWP transaction.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
response
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns the resulting response object from an LWP transaction.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
separator
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Sets the record (line) separator to whatever value you pass it.
|
|
Packit |
800465 |
Default is \n. Affects the chomp setting too.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
string_ref
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a reference to the internal string that is acting like a
|
|
Packit |
800465 |
file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
subject
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the subject for a mailto transaction.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
to
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the recipient address for a mailto request.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
uri
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Direct access to the URI used in LWP transactions.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
user
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Set the user name for an LWP transaction.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO Action Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
These are the methods that actually perform I/O operations on an
|
|
Packit |
800465 |
IO::All object. The stat methods and the File::Spec methods are
|
|
Packit |
800465 |
documented in separate sections below.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
accept
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For sockets. Opens a server socket (LISTEN => 1, REUSE => 1). Returns
|
|
Packit |
800465 |
an IO::All socket object that you are listening on.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If the fork method was called on the object, the process will
|
|
Packit |
800465 |
automatically be forked for every connection.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
all
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Read all contents into a single string.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
compare(io('file1')->all, io('file2')->all);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
all (For directories)
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a list of IO::All objects for all files and subdirectories in
|
|
Packit |
800465 |
a directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
'.' and '..' are excluded.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Takes an optional argument telling how many directories deep to
|
|
Packit |
800465 |
search. The default is 1. Zero (0) means search as deep as possible.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The filter method can be used to limit the results.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The items returned are sorted by name unless ->sort(0) is used.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all(0).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
all_dirs
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all, but only return directories.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All_Dirs
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all_dirs(0).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
all_files
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all, but only return files.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All_Files
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all_files(0).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
all_links
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all, but only return links.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
All_Links
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as all_links(0).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
append
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as print, but sets the file mode to '>>'.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
appendf
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as printf, but sets the file mode to '>>'.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
appendln
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as println, but sets the file mode to '>>'.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
clear
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Clear the internal buffer. This method is called by write after it
|
|
Packit |
800465 |
writes the buffer. Returns the object reference for chaining.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
close
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Close will basically unopen the object, which has different meanings
|
|
Packit |
800465 |
for different objects. For files and directories it will close and
|
|
Packit |
800465 |
release the handle. For sockets it calls shutdown. For tied things it
|
|
Packit |
800465 |
unties them, and it unlocks locked things.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
copy
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Copies the object to the path passed. Works on both files and
|
|
Packit |
800465 |
directories, but directories require File::Copy::Recursive to be
|
|
Packit |
800465 |
installed.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
empty
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns true if a file exists but has no size, or if a directory
|
|
Packit |
800465 |
exists but has no contents.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
eof
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::eof
|
|
Packit |
800465 |
|
|
Packit |
800465 |
ext
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns the extension of the file. Can also be spelled as extension
|
|
Packit |
800465 |
|
|
Packit |
800465 |
exists
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns whether or not the file or directory exists.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
filename
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the name portion of the file path in the object. For example:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('my/path/file.txt')->filename;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
would return file.txt.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
fileno
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::fileno
|
|
Packit |
800465 |
|
|
Packit |
800465 |
filepath
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the path portion of the file path in the object. For example:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io('my/path/file.txt')->filepath;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
would return my/path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
get
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Perform an LWP GET request manually.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
getc
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::getc
|
|
Packit |
800465 |
|
|
Packit |
800465 |
getline
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Calls IO::File::getline. You can pass in an optional record
|
|
Packit |
800465 |
separator.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
getlines
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Calls IO::File::getlines. You can pass in an optional record
|
|
Packit |
800465 |
separator.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
glob
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Creates IO::All objects for the files matching the glob in the
|
|
Packit |
800465 |
IO::All::Dir. For example:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->dir($ENV{HOME})->glob('*.txt')
|
|
Packit |
800465 |
|
|
Packit |
800465 |
head
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the first 10 lines of a file. Takes an optional argument which
|
|
Packit |
800465 |
is the number of lines to return. Works as expected in list and
|
|
Packit |
800465 |
scalar context. Is subject to the current line separator.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io_handle
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Direct access to the actual IO::Handle object being used on an opened
|
|
Packit |
800465 |
IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_dir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_executable
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns true if file or directory is executable.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_dbm
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a dbm file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_file
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_link
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a symlink.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_mldbm
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a mldbm file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_open
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Indicates whether the IO::All is currently open for input/output.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_pipe
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a pipe operation.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_readable
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns true if file or directory is readable.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_socket
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a socket.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_stdio
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a STDIO file handle.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_string
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
an in memory filehandle.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_temp
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns boolean telling whether or not the IO::All object represents
|
|
Packit |
800465 |
a temporary file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_writable
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns true if file or directory is writable. Can also be spelled as
|
|
Packit |
800465 |
is_writeable.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
length
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the length of the internal buffer.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mimetype
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the mimetype of the file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Requires a working installation of the File::MimeInfo CPAN module.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mkdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Create the directory represented by the object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mkpath
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Create the directory represented by the object, when the path
|
|
Packit |
800465 |
contains more than one directory that doesn't exist. Proxy for
|
|
Packit |
800465 |
File::Path::mkpath.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
next
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For a directory, this will return a new IO::All object for each file
|
|
Packit |
800465 |
or subdirectory in the directory. Return undef on EOD.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
open
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Open the IO::All object. Takes two optional arguments mode and perms,
|
|
Packit |
800465 |
which can also be set ahead of time using the mode and perms methods.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
NOTE: Normally you won't need to call open (or mode/perms), since
|
|
Packit |
800465 |
this happens automatically for most operations.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
os
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Change the object's os representation. Valid options are: win32,
|
|
Packit |
800465 |
unix, vms, mac, os2.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
pathname
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the absolute or relative pathname for a file or directory,
|
|
Packit |
800465 |
depending on whether object is in absolute or relative mode.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
print
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::print
|
|
Packit |
800465 |
|
|
Packit |
800465 |
printf
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::printf
|
|
Packit |
800465 |
|
|
Packit |
800465 |
println
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as print, but adds newline to each argument unless it already
|
|
Packit |
800465 |
ends with one.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
put
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Perform an LWP PUT request manually.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
read
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This method varies depending on its context. Read carefully (no pun
|
|
Packit |
800465 |
intended).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For a file, this will proxy IO::File::read. This means you must pass
|
|
Packit |
800465 |
it a buffer, a length to read, and optionally a buffer offset for
|
|
Packit |
800465 |
where to put the data that is read. The function returns the length
|
|
Packit |
800465 |
actually read (which is zero at EOF).
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If you don't pass any arguments for a file, IO::All will use its own
|
|
Packit |
800465 |
internal buffer, a default length, and the offset will always point
|
|
Packit |
800465 |
at the end of the buffer. The buffer can be accessed with the buffer
|
|
Packit |
800465 |
method. The length can be set with the block_size method. The default
|
|
Packit |
800465 |
length is 1024 bytes. The clear method can be called to clear the
|
|
Packit |
800465 |
buffer.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For a directory, this will proxy IO::Dir::read.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
readdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Similar to the Perl readdir builtin. In scalar context, return the
|
|
Packit |
800465 |
next directory entry (ie file or directory name), or undef on end of
|
|
Packit |
800465 |
directory. In list context, return all directory entries.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Note that readdir does not return the special . and .. entries.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
readline
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as getline.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
readlink
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Calls Perl's readlink function on the link represented by the object.
|
|
Packit |
800465 |
Instead of returning the file path, it returns a new IO::All object
|
|
Packit |
800465 |
using the file path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
recv
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Socket::recv
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rename
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $new = $io->rename('new-name');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Calls Perl's rename function and returns an IO::All object for the
|
|
Packit |
800465 |
renamed file. Returns false if the rename failed.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rewind
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Dir::rewind
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rmdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Delete the directory represented by the IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rmtree
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Delete the directory represented by the IO::All object and all the
|
|
Packit |
800465 |
files and directories beneath it. Proxy for File::Path::rmtree.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
scalar
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Deprecated. Same as all().
|
|
Packit |
800465 |
|
|
Packit |
800465 |
seek
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::seek. If you use seek on an unopened file, it
|
|
Packit |
800465 |
will be opened for both read and write.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
send
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Socket::send
|
|
Packit |
800465 |
|
|
Packit |
800465 |
shutdown
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Socket::shutdown
|
|
Packit |
800465 |
|
|
Packit |
800465 |
slurp
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Read all file content in one operation. Returns the file content as a
|
|
Packit |
800465 |
string. In list context returns every line in the file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
stat
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::stat
|
|
Packit |
800465 |
|
|
Packit |
800465 |
sysread
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::sysread
|
|
Packit |
800465 |
|
|
Packit |
800465 |
syswrite
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::syswrite
|
|
Packit |
800465 |
|
|
Packit |
800465 |
tail
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Return the last 10 lines of a file. Takes an optional argument which
|
|
Packit |
800465 |
is the number of lines to return. Works as expected in list and
|
|
Packit |
800465 |
scalar context. Is subject to the current line separator.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
tell
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::tell
|
|
Packit |
800465 |
|
|
Packit |
800465 |
throw
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This is an internal method that gets called whenever there is an
|
|
Packit |
800465 |
error. It could be useful to override it in a subclass, to provide
|
|
Packit |
800465 |
more control in error handling.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
touch
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Update the atime and mtime values for a file or directory. Creates an
|
|
Packit |
800465 |
empty file if the file does not exist.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
truncate
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for IO::Handle::truncate
|
|
Packit |
800465 |
|
|
Packit |
800465 |
type
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a string indicated the type of io object. Possible values
|
|
Packit |
800465 |
are:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
file
|
|
Packit |
800465 |
dir
|
|
Packit |
800465 |
link
|
|
Packit |
800465 |
socket
|
|
Packit |
800465 |
string
|
|
Packit |
800465 |
pipe
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns undef if type is not determinable.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
unlink
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Unlink (delete) the file represented by the IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
NOTE: You can unlink a file after it is open, and continue using it
|
|
Packit |
800465 |
until it is closed.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
unlock
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Release a lock from an object that used the lock method.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
utime
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Proxy for the utime Perl function.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
write
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Opposite of read for file operations only.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
NOTE: When used with the automatic internal buffer, write will clear
|
|
Packit |
800465 |
the buffer after writing it.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Stat Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This methods get individual values from a stat call on the file,
|
|
Packit |
800465 |
directory or handle represented by the IO::All object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
atime
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Last access time in seconds since the epoch
|
|
Packit |
800465 |
|
|
Packit |
800465 |
blksize
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Preferred block size for file system I/O
|
|
Packit |
800465 |
|
|
Packit |
800465 |
blocks
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Actual number of blocks allocated
|
|
Packit |
800465 |
|
|
Packit |
800465 |
ctime
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Inode change time in seconds since the epoch
|
|
Packit |
800465 |
|
|
Packit |
800465 |
device
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Device number of filesystem
|
|
Packit |
800465 |
|
|
Packit |
800465 |
device_id
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Device identifier for special files only
|
|
Packit |
800465 |
|
|
Packit |
800465 |
gid
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Numeric group id of file's owner
|
|
Packit |
800465 |
|
|
Packit |
800465 |
inode
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Inode number
|
|
Packit |
800465 |
|
|
Packit |
800465 |
modes
|
|
Packit |
800465 |
|
|
Packit |
800465 |
File mode - type and permissions
|
|
Packit |
800465 |
|
|
Packit |
800465 |
mtime
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Last modify time in seconds since the epoch
|
|
Packit |
800465 |
|
|
Packit |
800465 |
nlink
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Number of hard links to the file
|
|
Packit |
800465 |
|
|
Packit |
800465 |
size
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Total size of file in bytes
|
|
Packit |
800465 |
|
|
Packit |
800465 |
uid
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Numeric user id of file's owner
|
|
Packit |
800465 |
|
|
Packit |
800465 |
File::Spec Methods
|
|
Packit |
800465 |
|
|
Packit |
800465 |
These methods are all adaptations from File::Spec. Each method actually
|
|
Packit |
800465 |
does call the matching File::Spec method, but the arguments and return
|
|
Packit |
800465 |
values differ slightly. Instead of being file and directory names, they
|
|
Packit |
800465 |
are IO::All objects. Since IO::All objects stringify to their names,
|
|
Packit |
800465 |
you can generally use the methods just like File::Spec.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
abs2rel
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns the relative path for the absolute path in the IO::All
|
|
Packit |
800465 |
object. Can take an optional argument indicating the base path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
canonpath
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns the canonical path for the IO::All object. The canonical path
|
|
Packit |
800465 |
is the fully resolved path if the file exists, so any symlinks will
|
|
Packit |
800465 |
be resolved.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
case_tolerant
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns 0 or 1 indicating whether the file system is case tolerant.
|
|
Packit |
800465 |
Since an active IO::All object is not needed for this function, you
|
|
Packit |
800465 |
can code it like:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO::All->case_tolerant;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
or more simply:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
io->case_tolerant;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
catdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Concatenate the directory components together, and return a new
|
|
Packit |
800465 |
IO::All object representing the resulting directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
catfile
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Concatenate the directory and file components together, and return a
|
|
Packit |
800465 |
new IO::All object representing the resulting file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $contents = io->catfile(qw(dir subdir file))->slurp;
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This is a very portable way to read dir/subdir/file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
catpath
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Concatenate the volume, directory and file components together, and
|
|
Packit |
800465 |
return a new IO::All object representing the resulting file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
curdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns an IO::All object representing the current directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
devnull
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns an IO::All object representing the /dev/null file.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
is_absolute
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns 0 or 1 indicating whether the name field of the IO::All
|
|
Packit |
800465 |
object is an absolute path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
join
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Same as catfile.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
path
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a list of IO::All directory objects for each directory in
|
|
Packit |
800465 |
your path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rel2abs
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns the absolute path for the relative path in the IO::All
|
|
Packit |
800465 |
object. Can take an optional argument indicating the base path.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
rootdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns an IO::All object representing the root directory on your
|
|
Packit |
800465 |
file system.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
splitdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a list of the directory components of a path in an IO::All
|
|
Packit |
800465 |
object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
splitpath
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns a volume directory and file component of a path in an IO::All
|
|
Packit |
800465 |
object.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
tmpdir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns an IO::All object representing a temporary directory on your
|
|
Packit |
800465 |
file system.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
updir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Returns an IO::All object representing the current parent directory.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
OPERATIONAL NOTES
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Reblessing
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Each IO::All object gets reblessed into an IO::All::* object as soon
|
|
Packit |
800465 |
as IO::All can determine what type of object it should be. Sometimes
|
|
Packit |
800465 |
it gets reblessed more than once:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $io = io('mydbm.db');
|
|
Packit |
800465 |
$io->dbm('DB_File');
|
|
Packit |
800465 |
$io->{foo} = 'bar';
|
|
Packit |
800465 |
|
|
Packit |
800465 |
In the first statement, $io has a reference value of 'IO::All::File',
|
|
Packit |
800465 |
if mydbm.db exists. In the second statement, the object is reblessed
|
|
Packit |
800465 |
into class 'IO::All::DBM'.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Auto-Open
|
|
Packit |
800465 |
|
|
Packit |
800465 |
An IO::All object will automatically be opened as soon as there is
|
|
Packit |
800465 |
enough contextual information to know what type of object it is, and
|
|
Packit |
800465 |
what mode it should be opened for. This is usually when the first
|
|
Packit |
800465 |
read or write operation is invoked but might be sooner.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Auto-Mode
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The mode for an object to be opened with is determined heuristically
|
|
Packit |
800465 |
unless specified explicitly.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Auto-Close
|
|
Packit |
800465 |
|
|
Packit |
800465 |
For input, IO::All objects will automatically be closed after EOF (or
|
|
Packit |
800465 |
EOD). For output, the object closes when it goes out of scope.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
To keep input objects from closing at EOF, do this:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
$io->autoclose(0);
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Explicit open and close
|
|
Packit |
800465 |
|
|
Packit |
800465 |
You can always call open and close explicitly, if you need that level
|
|
Packit |
800465 |
of control. To test if an object is currently open, use the is_open
|
|
Packit |
800465 |
method.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Overload
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Overloaded operations return the target object, if one exists.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This would set $xxx to the IO::All object:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $xxx = $contents > io('file.txt');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
While this would set $xxx to the content string:
|
|
Packit |
800465 |
|
|
Packit |
800465 |
my $xxx = $contents < io('file.txt');
|
|
Packit |
800465 |
|
|
Packit |
800465 |
STABILITY
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The goal of the IO::All project is to continually refine the module to
|
|
Packit |
800465 |
be as simple and consistent to use as possible. Therefore, in the early
|
|
Packit |
800465 |
stages of the project, I will not hesitate to break backwards
|
|
Packit |
800465 |
compatibility with other versions of IO::All if I can find an easier
|
|
Packit |
800465 |
and clearer way to do a particular thing.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
IO is tricky stuff. There is definitely more work to be done. On the
|
|
Packit |
800465 |
other hand, this module relies heavily on very stable existing IO
|
|
Packit |
800465 |
modules; so it may work fairly well.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
I am sure you will find many unexpected "features". Please send all
|
|
Packit |
800465 |
problems, ideas and suggestions to ingy@cpan.org.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Known Bugs and Deficiencies
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Not all possible combinations of objects and methods have been tested.
|
|
Packit |
800465 |
There are many many combinations. All of the examples have been tested.
|
|
Packit |
800465 |
If you find a bug with a particular combination of calls, let me know.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
If you call a method that does not make sense for a particular object,
|
|
Packit |
800465 |
the result probably won't make sense. Little attempt is made to check
|
|
Packit |
800465 |
for improper usage.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
CREDITS
|
|
Packit |
800465 |
|
|
Packit |
800465 |
A lot of people have sent in suggestions, that have become a part of
|
|
Packit |
800465 |
IO::All. Thank you.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Special thanks to Ian Langworth for continued testing and patching.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Thank you Simon Cozens for tipping me off to the overloading
|
|
Packit |
800465 |
possibilities.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Finally, thanks to Autrijus Tang, for always having one more good idea.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
(It seems IO::All of it to a lot of people!)
|
|
Packit |
800465 |
|
|
Packit |
800465 |
REPOSITORY AND COMMUNITY
|
|
Packit |
800465 |
|
|
Packit |
800465 |
The IO::All module can be found on CPAN and on GitHub:
|
|
Packit |
800465 |
http://github.com/ingydotnet/io-all-pm.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Please join the IO::All discussion on #io-all on irc.perl.org.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
SEE ALSO
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* File::Spec
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* File::Path
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* File::ReadBackwards
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* File::MimeInfo
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* IO::Handle
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* IO::File
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* IO::Dir
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* IO::Socket
|
|
Packit |
800465 |
|
|
Packit |
800465 |
* Tie::File
|
|
Packit |
800465 |
|
|
Packit |
800465 |
AUTHOR
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Ingy döt Net <ingy@cpan.org>
|
|
Packit |
800465 |
|
|
Packit |
800465 |
COPYRIGHT AND LICENSE
|
|
Packit |
800465 |
|
|
Packit |
800465 |
Copyright 2004-2017. Ingy döt Net.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
This program is free software; you can redistribute it and/or modify it
|
|
Packit |
800465 |
under the same terms as Perl itself.
|
|
Packit |
800465 |
|
|
Packit |
800465 |
See http://www.perl.com/perl/misc/Artistic.html
|
|
Packit |
800465 |
|