
davorg
Thaumaturge
/ Moderator
Jan 6, 2003, 1:40 AM
Post #4 of 7
(995 views)
|
|
Re: [benchivers] NET::FTP Dir Listing Problem
[In reply to]
|
Can't Post
|
|
The code you have provided works fine until the interpreter reaches unpack. In my server error log is says 'Invalid Argument'. I simply copied the code provided and just added it into mine. Do you know what the problem might be? Oops yeah. I got the templates the wrong way round. Where I had
my $unpack = '10a4a5a7a15a12a*a'; It should have been
my $unpack = 'a10a4a5a7a15a12a*'; Sorry for the confusion. you would probably have been able to work out the problem yourself if you'd read the documentation for unpack which I directed you to.
I also have no idea how the code works, the only time I have had use for 'pack' and 'unpack' was for converting char to ascii and vice-versa. Please explain the code, I understand the foreach loop, but I have no idea what 'unpack' does to the variable in the for loop. Again, reading the documentation for unpack would be a good place to find out what "unpack" does :) Oh, and at the top of the page this site has just shown me an advert for that wonderful book Data Munging with Perl which has some great explainations on how "pack" and "unpack" work :)
As I couldn't get it working I finally used: foreach ($ftp->dir()){ @statarray = split(" ", $_, 9); }This gave me an array of stats for the file. It also works on filenames with spaces. Is this a good way of doing it? Yeah that seems ok. I'd be a bit more explicit about what I'm doing tho' and use -- Dave Cross, Perl Hacker, Trainer and Writer http://www.dave.org.uk/ Get more help at Perl Monks
|