Can't call method “filename” without a package or object reference
up vote
0
down vote
favorite
I want to download from a ftp server (host1) a bunch of directories with content. To do that I use library Net::FTP::Recursive. When I run the code the folders and files were downloaded. Nevertheless, I got this message:
>Can't call method "filename" without a package or object reference
at C:10_LIB~1PerlLiblibperl5/Net/FTP/Recursive.pm line 86.
I wonder why this happens, what impact it has and how I can avoid this.
Here is the code to download:
# -- Libraries
# coding and diagnostic
use strict;
use warnings;
# FTP connection
use Net::FTP;
use Net::FTP::Recursive;
# -- Settings
my $host1 = "ftp.host1.com";
my $user1 = "myname@myweb.com";
my $password1 = "password";
# -- Connection to ftp server
my $f1 = Net::FTP::Recursive->new($host1) or die "Can't open $f1 $host1n";
$f1->login($user1, $password1) or die "Can't log $f1 $user1 inn";
$f1->cwd() or die "Can't cwd to host foldern";
# $f1->ascii();
$f1->binary;
# -- Directory to download the contents
my $download = "C:/mydirectory/download";
chdir($download);
# -- Host1
$f1->cwd();
$f1->rget( ParseSub => &yoursub1 );
$f1->quit;
sub yoursub1 {
$f1->rget;
}
I used perl on Windows 7 with version:
perl -v
This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x64-multi-thread
And here is the code from /Net/FTP/Recursive.pm until line 86 from the message:
sub _rget {
my($ftp) = shift;
my @dirs;
my @ls = $ftp->dir();
my @files = $options{ParseSub}->( @ls );
@files = grep { $_->filename =~ $options{MatchAll} } @files
if $options{MatchAll};
@files = grep { $_->filename !~ $options{OmitAll} } @files
if $options{OmitAll};
print STDERR join("n", @ls), "n"
if $ftp->debug;
my $remote_pwd = $ftp->pwd;
my $local_pwd = Cwd::cwd();
FILE:
foreach my $file (@files){
#used to make sure that if we're deleting the files, we
#successfully retrieved the file
my $get_success = 1;
my $filename = $file->filename(); # <- 86
perl ftp net-ftp
add a comment |
up vote
0
down vote
favorite
I want to download from a ftp server (host1) a bunch of directories with content. To do that I use library Net::FTP::Recursive. When I run the code the folders and files were downloaded. Nevertheless, I got this message:
>Can't call method "filename" without a package or object reference
at C:10_LIB~1PerlLiblibperl5/Net/FTP/Recursive.pm line 86.
I wonder why this happens, what impact it has and how I can avoid this.
Here is the code to download:
# -- Libraries
# coding and diagnostic
use strict;
use warnings;
# FTP connection
use Net::FTP;
use Net::FTP::Recursive;
# -- Settings
my $host1 = "ftp.host1.com";
my $user1 = "myname@myweb.com";
my $password1 = "password";
# -- Connection to ftp server
my $f1 = Net::FTP::Recursive->new($host1) or die "Can't open $f1 $host1n";
$f1->login($user1, $password1) or die "Can't log $f1 $user1 inn";
$f1->cwd() or die "Can't cwd to host foldern";
# $f1->ascii();
$f1->binary;
# -- Directory to download the contents
my $download = "C:/mydirectory/download";
chdir($download);
# -- Host1
$f1->cwd();
$f1->rget( ParseSub => &yoursub1 );
$f1->quit;
sub yoursub1 {
$f1->rget;
}
I used perl on Windows 7 with version:
perl -v
This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x64-multi-thread
And here is the code from /Net/FTP/Recursive.pm until line 86 from the message:
sub _rget {
my($ftp) = shift;
my @dirs;
my @ls = $ftp->dir();
my @files = $options{ParseSub}->( @ls );
@files = grep { $_->filename =~ $options{MatchAll} } @files
if $options{MatchAll};
@files = grep { $_->filename !~ $options{OmitAll} } @files
if $options{OmitAll};
print STDERR join("n", @ls), "n"
if $ftp->debug;
my $remote_pwd = $ftp->pwd;
my $local_pwd = Cwd::cwd();
FILE:
foreach my $file (@files){
#used to make sure that if we're deleting the files, we
#successfully retrieved the file
my $get_success = 1;
my $filename = $file->filename(); # <- 86
perl ftp net-ftp
2
Enable debugging to see if any other messages appear:my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
2
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
@toolic I addDEBUG => 1
and there was no other message.
– giordano
Nov 10 at 10:28
Now it is obsolete but correct debugging isDebug => 1
and notDEBUG => Y 1
.
– giordano
Nov 10 at 13:52
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to download from a ftp server (host1) a bunch of directories with content. To do that I use library Net::FTP::Recursive. When I run the code the folders and files were downloaded. Nevertheless, I got this message:
>Can't call method "filename" without a package or object reference
at C:10_LIB~1PerlLiblibperl5/Net/FTP/Recursive.pm line 86.
I wonder why this happens, what impact it has and how I can avoid this.
Here is the code to download:
# -- Libraries
# coding and diagnostic
use strict;
use warnings;
# FTP connection
use Net::FTP;
use Net::FTP::Recursive;
# -- Settings
my $host1 = "ftp.host1.com";
my $user1 = "myname@myweb.com";
my $password1 = "password";
# -- Connection to ftp server
my $f1 = Net::FTP::Recursive->new($host1) or die "Can't open $f1 $host1n";
$f1->login($user1, $password1) or die "Can't log $f1 $user1 inn";
$f1->cwd() or die "Can't cwd to host foldern";
# $f1->ascii();
$f1->binary;
# -- Directory to download the contents
my $download = "C:/mydirectory/download";
chdir($download);
# -- Host1
$f1->cwd();
$f1->rget( ParseSub => &yoursub1 );
$f1->quit;
sub yoursub1 {
$f1->rget;
}
I used perl on Windows 7 with version:
perl -v
This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x64-multi-thread
And here is the code from /Net/FTP/Recursive.pm until line 86 from the message:
sub _rget {
my($ftp) = shift;
my @dirs;
my @ls = $ftp->dir();
my @files = $options{ParseSub}->( @ls );
@files = grep { $_->filename =~ $options{MatchAll} } @files
if $options{MatchAll};
@files = grep { $_->filename !~ $options{OmitAll} } @files
if $options{OmitAll};
print STDERR join("n", @ls), "n"
if $ftp->debug;
my $remote_pwd = $ftp->pwd;
my $local_pwd = Cwd::cwd();
FILE:
foreach my $file (@files){
#used to make sure that if we're deleting the files, we
#successfully retrieved the file
my $get_success = 1;
my $filename = $file->filename(); # <- 86
perl ftp net-ftp
I want to download from a ftp server (host1) a bunch of directories with content. To do that I use library Net::FTP::Recursive. When I run the code the folders and files were downloaded. Nevertheless, I got this message:
>Can't call method "filename" without a package or object reference
at C:10_LIB~1PerlLiblibperl5/Net/FTP/Recursive.pm line 86.
I wonder why this happens, what impact it has and how I can avoid this.
Here is the code to download:
# -- Libraries
# coding and diagnostic
use strict;
use warnings;
# FTP connection
use Net::FTP;
use Net::FTP::Recursive;
# -- Settings
my $host1 = "ftp.host1.com";
my $user1 = "myname@myweb.com";
my $password1 = "password";
# -- Connection to ftp server
my $f1 = Net::FTP::Recursive->new($host1) or die "Can't open $f1 $host1n";
$f1->login($user1, $password1) or die "Can't log $f1 $user1 inn";
$f1->cwd() or die "Can't cwd to host foldern";
# $f1->ascii();
$f1->binary;
# -- Directory to download the contents
my $download = "C:/mydirectory/download";
chdir($download);
# -- Host1
$f1->cwd();
$f1->rget( ParseSub => &yoursub1 );
$f1->quit;
sub yoursub1 {
$f1->rget;
}
I used perl on Windows 7 with version:
perl -v
This is perl 5, version 28, subversion 0 (v5.28.0) built for MSWin32-x64-multi-thread
And here is the code from /Net/FTP/Recursive.pm until line 86 from the message:
sub _rget {
my($ftp) = shift;
my @dirs;
my @ls = $ftp->dir();
my @files = $options{ParseSub}->( @ls );
@files = grep { $_->filename =~ $options{MatchAll} } @files
if $options{MatchAll};
@files = grep { $_->filename !~ $options{OmitAll} } @files
if $options{OmitAll};
print STDERR join("n", @ls), "n"
if $ftp->debug;
my $remote_pwd = $ftp->pwd;
my $local_pwd = Cwd::cwd();
FILE:
foreach my $file (@files){
#used to make sure that if we're deleting the files, we
#successfully retrieved the file
my $get_success = 1;
my $filename = $file->filename(); # <- 86
perl ftp net-ftp
perl ftp net-ftp
asked Nov 9 at 16:53
giordano
98121533
98121533
2
Enable debugging to see if any other messages appear:my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
2
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
@toolic I addDEBUG => 1
and there was no other message.
– giordano
Nov 10 at 10:28
Now it is obsolete but correct debugging isDebug => 1
and notDEBUG => Y 1
.
– giordano
Nov 10 at 13:52
add a comment |
2
Enable debugging to see if any other messages appear:my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
2
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
@toolic I addDEBUG => 1
and there was no other message.
– giordano
Nov 10 at 10:28
Now it is obsolete but correct debugging isDebug => 1
and notDEBUG => Y 1
.
– giordano
Nov 10 at 13:52
2
2
Enable debugging to see if any other messages appear:
my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
Enable debugging to see if any other messages appear:
my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
2
2
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
@toolic I add
DEBUG => 1
and there was no other message.– giordano
Nov 10 at 10:28
@toolic I add
DEBUG => 1
and there was no other message.– giordano
Nov 10 at 10:28
Now it is obsolete but correct debugging is
Debug => 1
and not DEBUG => Y 1
.– giordano
Nov 10 at 13:52
Now it is obsolete but correct debugging is
Debug => 1
and not DEBUG => Y 1
.– giordano
Nov 10 at 13:52
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
yoursub1
is completely wrong. It's suppose to parse the lines returned from the FTP server (provided as arguments to the sub), and return a list of Net::FTP::Recursive::File objects for each remote file (other than .
and ..
).
If the default implementation (Net::FTP::Recursive::parse_files
) is sufficient, simply remove ParseSub => &yoursub1
. Otherwise, you should probably start by copying Net::FTP::Recursive::parse_files
and adjusting it for your FTP server's output.
I removed the functionyoursub1
and the argument inf1->rget()
. At the end I have onlyf1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.
– giordano
Nov 10 at 10:47
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
yoursub1
is completely wrong. It's suppose to parse the lines returned from the FTP server (provided as arguments to the sub), and return a list of Net::FTP::Recursive::File objects for each remote file (other than .
and ..
).
If the default implementation (Net::FTP::Recursive::parse_files
) is sufficient, simply remove ParseSub => &yoursub1
. Otherwise, you should probably start by copying Net::FTP::Recursive::parse_files
and adjusting it for your FTP server's output.
I removed the functionyoursub1
and the argument inf1->rget()
. At the end I have onlyf1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.
– giordano
Nov 10 at 10:47
add a comment |
up vote
3
down vote
accepted
yoursub1
is completely wrong. It's suppose to parse the lines returned from the FTP server (provided as arguments to the sub), and return a list of Net::FTP::Recursive::File objects for each remote file (other than .
and ..
).
If the default implementation (Net::FTP::Recursive::parse_files
) is sufficient, simply remove ParseSub => &yoursub1
. Otherwise, you should probably start by copying Net::FTP::Recursive::parse_files
and adjusting it for your FTP server's output.
I removed the functionyoursub1
and the argument inf1->rget()
. At the end I have onlyf1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.
– giordano
Nov 10 at 10:47
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
yoursub1
is completely wrong. It's suppose to parse the lines returned from the FTP server (provided as arguments to the sub), and return a list of Net::FTP::Recursive::File objects for each remote file (other than .
and ..
).
If the default implementation (Net::FTP::Recursive::parse_files
) is sufficient, simply remove ParseSub => &yoursub1
. Otherwise, you should probably start by copying Net::FTP::Recursive::parse_files
and adjusting it for your FTP server's output.
yoursub1
is completely wrong. It's suppose to parse the lines returned from the FTP server (provided as arguments to the sub), and return a list of Net::FTP::Recursive::File objects for each remote file (other than .
and ..
).
If the default implementation (Net::FTP::Recursive::parse_files
) is sufficient, simply remove ParseSub => &yoursub1
. Otherwise, you should probably start by copying Net::FTP::Recursive::parse_files
and adjusting it for your FTP server's output.
answered Nov 9 at 22:12
ikegami
259k11172392
259k11172392
I removed the functionyoursub1
and the argument inf1->rget()
. At the end I have onlyf1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.
– giordano
Nov 10 at 10:47
add a comment |
I removed the functionyoursub1
and the argument inf1->rget()
. At the end I have onlyf1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.
– giordano
Nov 10 at 10:47
I removed the function
yoursub1
and the argument in f1->rget()
. At the end I have only f1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.– giordano
Nov 10 at 10:47
I removed the function
yoursub1
and the argument in f1->rget()
. At the end I have only f1->cwd(); f1->rget();f1->quit();
. This works!. Again, you saved my day.– giordano
Nov 10 at 10:47
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230107%2fcant-call-method-filename-without-a-package-or-object-reference%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Enable debugging to see if any other messages appear:
my $f1 = Net::FTP::Recursive->new($host1, DEBUG => 1)
– toolic
Nov 9 at 17:13
2
This is also helpful (albeit extremely verbose): Devel::DumpTrace
– toolic
Nov 9 at 17:18
@toolic I add
DEBUG => 1
and there was no other message.– giordano
Nov 10 at 10:28
Now it is obsolete but correct debugging is
Debug => 1
and notDEBUG => Y 1
.– giordano
Nov 10 at 13:52