Skip Menu |

This queue is for tickets about the libnet CPAN distribution.

Report information
The Basics
Id: 27560
Status: rejected
Priority: 0/
Queue: libnet

People
Owner: Nobody in particular
Requestors: rkitover [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.21
Fixed in: (no value)



Subject: Allow for autoclose of FTP::dataconn objects
This patch allows using things like for (@files) { my $dataconn = $ftp->retr($_) while (<$dataconn>) { ... do stuff } } Without doing an explicit $dataconn->close. Patch below. --- libnet-1.21-HFRVUZ/Net/FTP.pm 2007-05-19 06:56:18.000000000 -0700 +++ FTP.pm 2007-06-13 00:59:15.000000000 -0700 @@ -19,6 +19,7 @@ use Time::Local; use Net::Cmd; use Net::Config; +use Scalar::Util 'weaken'; use Fcntl qw(O_WRONLY O_RDONLY O_APPEND O_CREAT O_TRUNC); $VERSION = '2.77'; @@ -942,6 +943,7 @@ ${*$data} = ""; $data->timeout($ftp->timeout); ${*$ftp}{'net_ftp_dataconn'} = $data; + weaken ${*$ftp}{'net_ftp_dataconn'}; ${*$data}{'net_ftp_cmd'} = $ftp; ${*$data}{'net_ftp_blksize'} = ${*$ftp}{'net_ftp_blksize'}; } --- libnet-1.21-HFRVUZ/Net/FTP/dataconn.pm 2007-05-19 06:56:17.000000000 -0700 +++ FTP/dataconn.pm 2007-06-13 00:59:27.000000000 -0700 @@ -77,6 +77,11 @@ } +sub DESTROY { + $_[0]->close +} + + sub _select { my ($data, $timeout, $do_read) = @_; my ($rin, $rout, $win, $wout, $tout, $nfound);