G
Graham Wood
I've written an FTP client using the GUI Loft and Net::FTP. I've
managed to get the program to work by scoping the $ftp object with "our"
but I don't think this is how you are supposed to do it.
Here's an artist's impression of what I'm doing now:
our $ftp= Net::FTP->new("hostname")|| die "Can't create FTP object";
sub ::btnChdir_Click{
our $ftp;
# get $path from value in a text box
$ftp->cwd("$path");
}
sub ::btnOK_Click{
our $ftp;
$ftp->put("$file");
}
sub ::btnDisconnect_Click{
our $ftp;
$ftp->quit();
}
I know that I could pass the $ftp object as an argument to subroutines
if I were calling them from my script but in this event driven model,
how do I elegantly pick up the value of the existing ftp object without
letting it all hang out in this unseemly fashion?
I notice that the gui $win object is picked up with code like this:
defined(my $win = $Win32::GUI::Loft::window(winCopyFiles})
or return (1);
Can I do something similar with Net::FTP objects like
defined(my $ftp = $Net::FTP);
Any hints gratefully accepted.
Thanks
Graham
managed to get the program to work by scoping the $ftp object with "our"
but I don't think this is how you are supposed to do it.
Here's an artist's impression of what I'm doing now:
our $ftp= Net::FTP->new("hostname")|| die "Can't create FTP object";
sub ::btnChdir_Click{
our $ftp;
# get $path from value in a text box
$ftp->cwd("$path");
}
sub ::btnOK_Click{
our $ftp;
$ftp->put("$file");
}
sub ::btnDisconnect_Click{
our $ftp;
$ftp->quit();
}
I know that I could pass the $ftp object as an argument to subroutines
if I were calling them from my script but in this event driven model,
how do I elegantly pick up the value of the existing ftp object without
letting it all hang out in this unseemly fashion?
I notice that the gui $win object is picked up with code like this:
defined(my $win = $Win32::GUI::Loft::window(winCopyFiles})
or return (1);
Can I do something similar with Net::FTP objects like
defined(my $ftp = $Net::FTP);
Any hints gratefully accepted.
Thanks
Graham