Jan 6, 2003, 1:40 AM
Post #4 of 7
Re: [benchivers] NET::FTP Dir Listing Problem
[In reply to]
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
It should have been
my $unpack = '10a4a5a7a15a12a*a';
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.
my $unpack = 'a10a4a5a7a15a12a*';
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:
@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
Get more help at Perl Monks