Re: Net::SFTP::Attributes
- From: "Paul Lalli" <mritty@xxxxxxxxx>
- Date: 23 Oct 2006 12:48:23 -0700
bmaynard@xxxxxxxxxxxx wrote:
Okay you are right perhaps an example would help. I am doing this:
my @files = @{ $sftp->ls( } ) };
foreach my $ref ( @files )
{
next if $ref->{filename} eq "." || $ref->{filename} eq "..";
print $ref->{filename} . "\n"
}
However, no matter what I do dealing with $ref always seems to be
empty.
You really need to work on your usage of terminology when talking in
technical forums. "empty" is a term that applies to lists, arrays, and
hashes. It has no definate meaning for scalars. I don't know if you
mean that $ref is the empty string, or $ref is undefined, or $ref is a
reference to an empty array or an empty hash, or something else
entirely.
When I refer to 'handle' I mean how I am supposed to handle the
object I am not referring to file handles or any other type of handle,
I did not think you meant filehandles. I know you're using the word
'handle' as a verb. That still doesn't have any meaning. What does it
mean to "handle" the object? There are several things you can do to
objects. You can access their underlying referenced structures, you
can call their methods, etc. I don't know what you're trying to do
when you say "handle the object".
just the fact that I have data coming in, but I am not sure how I can
get my script to handle the data since there I don't seem to be able to
access the contents of the Net::SFTP::Attributes object.
Okay, now that you've posted code, we can see what the actual problem
is. You've made no attempt above to access the Net::SFTP::Attributes
object. I'm guessing you've misread the documentation for the ls()
method of the Net::SFTP class. It says:
=======================================
$sftp->ls($remote [, $subref ])
Fetches a directory listing of $remote.
If $subref is specified, for each entry in the directory, $subref will
be called and given a reference to a hash with three keys: filename,
the name of the entry in the directory listing; longname, an entry in a
"long" listing like ls -l; and a, a Net::SFTP::Attributes object, which
contains the file attributes of the entry (atime, mtime, permissions,
etc.).
If $subref is not specified, returns a list of directory entries, each
of which is a reference to a hash as described in the previous
paragraph.
=======================================
So in your code, $ref is not a Net::SFTP::Attribute object. $ref is a
reference to a hash. That hash contains three key/value pairs. ONE of
those keys is 'a', and the value at that key is a Net::SFTP::Attribute
object.
Now, since you were not attempting to access any method of
Net::SFTP::Attribute, I have to assume that the mention of that entire
class is a gigantic red herring. So what is the *actual* problem
you're seeing with the above code? Is the loop not executing at all?
Is it looping through, but every $ref->{filename} is blank?
What debugging have you done for this? Have you printed out the
contents of $conf{'remdir'} to confirm it is what you think it is?
Have you printed Dumper(\@files) to see what's actually in this array?
Paul Lalli
.
- Follow-Ups:
- Re: Net::SFTP::Attributes
- From: Ben
- Re: Net::SFTP::Attributes
- References:
- Net::SFTP::Attributes
- From: bmaynard
- Re: Net::SFTP::Attributes
- From: Paul Lalli
- Re: Net::SFTP::Attributes
- From: bmaynard
- Re: Net::SFTP::Attributes
- From: Paul Lalli
- Re: Net::SFTP::Attributes
- From: bmaynard
- Net::SFTP::Attributes
- Prev by Date: Re: Net::SFTP::Attributes
- Next by Date: Error installing Apache::Request
- Previous by thread: Re: Net::SFTP::Attributes
- Next by thread: Re: Net::SFTP::Attributes
- Index(es):
Relevant Pages
|