VFS::Gnome - Gnome Virtual Filesystem for Perl
use VFS::Gnome; vfsopen(*IN, "<http://www.piersharding.com") or die $!; # dont forget the * when using strict print while (<IN>); close IN;
VFS::Gnome is a TIEHANDLE module that uses the gnome-vfs library from the Gnome project (http://www.gnome.org). The gnome-vfs library (Virtual File System) allows uniform access to various uri types such as http://, https://, file://, ftp:// etc.
vfsopen is pushed into the users calling namespace via the import statement, so there is no need to fully qualify it.
vfsopen(*FH, ">file:///tmp/some.file") or die $!;
Because use strict forbids the use of barewords, then you must remember to use the * (typeglob notation) on your filehandle - but only for the vfsopen there after it is not required.
VFS::Gnome supports:
'>' output to a file
'<' input from a file
'>>' append to a file ( this is broken in RH8.0 as gnome_vfs_seek is broken )
once opened - a file handle behaves much like an ordinary one, in that you can "print" to it, and read from it with the "<>" (diamond) operator.
vfsstat takes a single argument of a uri and returns a 13 element array of information as the core perl stat() function does.
vfsexists takes a single argument of a uri and returns true if it exists.
vfsmove takes two arguments - the from and to uri's, and returns true if the file was successfully transported.
vfsunlink takes a single argument of a uri and returns true if the file is successfully unlinked/deleted.
vfsopendir opens a handle on a directory in the same style as a TIED files handle. This is used in preference to trying to imitate the opendir, readdir, closedir syntax of Perl, that can not be imitated thru the tie() operation.
vfsopendir(*DIR, "file:///tmp") or die $!;
Because use strict forbids the use of barewords, then you must remember to use the * (typeglob notation) on your filehandle - but only for the vfsopendir there after it is not required.
subsequently the handle can be addressed in two ways:
in array context
in scalar context
Array context emulates individual readdir commands of standard Perl, in that it returns a list of names read from the given directory.
push(@a, (<DIR>));
Scalar context returns the results of individual stat commands as an array ref. This is what gnome-vfs does natively. The first element of the stat array has been highjacked to supply the files name.
while($dirent = <DIR>) push(@a, $dirent->[0]);
very new
Piers Harding - piers@cpan.org
http://developer.gnome.org/doc/API/gnome-vfs/ and perldoc Tie::Handle
Copyright (c) 2002, Piers Harding. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install VFS::Gnome, copy and paste the appropriate command in to your terminal.
cpanm
cpanm VFS::Gnome
CPAN shell
perl -MCPAN -e shell install VFS::Gnome
For more information on module installation, please visit the detailed CPAN module installation guide.