Re: Net::SFTP::Attributes
- From: "Ben" <bmaynard@xxxxxxxxxxxx>
- Date: 25 Oct 2006 10:45:27 -0700
Wow condescending, okay yes I have been programming for about 9 years,
when I ask a simple question on the correct usage of a module I would
prefer to get an answer that relates to my question rather than a
trumped up self important rant on my usage of the terms 'empty' and
'handle', if that is be the best you have to offer I would prefer not
to get any answer.
The code I sent you was a very heavily truncated snippet since the
actual code contains information my employeers would prefer not be sent
out, I was just attempting to give an example of what I am attempting
to do.
On Oct 23, 3:48 pm, "Paul Lalli" <mri...@xxxxxxxxx> wrote:
bmayn...@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 betechnical forums. "empty" is a term that applies to lists, arrays, and
empty.You really need to work on your usage of terminology when talking in
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'handle' as a verb. That still doesn't have any meaning. What does it
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
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 canis. You've made no attempt above to access the Net::SFTP::Attributes
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
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: Paul Lalli
- 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
- Re: Net::SFTP::Attributes
- From: Paul Lalli
- Net::SFTP::Attributes
- Prev by Date: Re: net smtp help
- Next by Date: Re: Net::SFTP::Attributes
- Previous by thread: Re: Net::SFTP::Attributes
- Next by thread: Re: Net::SFTP::Attributes
- Index(es):
Relevant Pages
|