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









share|improve this question


















  • 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 not DEBUG => Y 1.
    – giordano
    Nov 10 at 13:52

















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









share|improve this question


















  • 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 not DEBUG => Y 1.
    – giordano
    Nov 10 at 13:52















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









share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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 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
















  • 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 not DEBUG => 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














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.






share|improve this answer





















  • 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













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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.






share|improve this answer





















  • 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

















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.






share|improve this answer





















  • 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















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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 9 at 22:12









ikegami

259k11172392




259k11172392












  • 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


















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




















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)