16 Sep 2006 11:08:47 UTC
- Distribution: Tie-FTP
- Module version: 0.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (534 / 19 / 0)
- KwaliteeBus factor: 1
- 52.42% Coverage
- License: unknown
- Activity24 month
- Download (3.61KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionIVORW Ivor Williams
Tie::FTP - A module to open files on FTP servers as filehandles
tie *FH,'Tie::FTP'; open FH,'ftp://user:password@host/file'; print while (<FH>); seek FH,0,0; print FH foo; close FH;
tie *FH,'Tie::FTP'; (tied *FH)->taint; my $fh = (tied *FH)->tmpfh; seek $fh,0,0; print $fh foo; close FH;
This module downloads a file on an FTP server into a temporary file, and allows editing on that. Upon destroy the object rewrites itself to the server if there were any write operations.
Since all the operations are actually delegated you're better off tying a gensym, and then using
my $fh = (tied $ftpfh)->tmpfh;. Just remember to call
(tied $ftpfh)->taint;if you want to commit changes at DESTROY time.
This method accepts either a URI string or object, or a logged in Net::FTP object and a path string.
In the former all login credentials are sucked out of the URI, and a Net::FTP object is created. See CAVEATS.
In the latter form the Net::FTP object is assumed to be connected, and the path string is a relative one.
The file will be written regardless of wether or not there are write permissions.
You may need to do
(tied $ftpfh)->ftp->noop;every once in a while, to stir things up.
Net::FTP and URI are not used from within the module as you may prefer to pass other types of objects, with a compatible interface.
Yuval Kogman <email@example.com>
This program is free software licensed under the...
The MIT License
The full text of the license can be found in the LICENSE file included with this module.