when you log on with ftp, you log on as a certain user, and the filesystem gives you access to things based on whether or not they have that user listed as having access to them (the permissions of the file), either because of the user's name, or one of the groups that user is included in. when you access a file through a web server, the webserver is generally running as user 'nobody', in group 'nobody', and nothing else. that means when you try to access a file (html file, cgi file, whatever), it only works if the type of access you're attempting is allowed for 'nobody', or, as is usually the general case, anyone.
for the question of why it's showing up differently with stat, i have two ideas. first, the third element is index [2], you may be accessing it wrong. second, the number is in octal, so the easiest way to view it would be a:
[tt]printf("%o", $info[2]);[/tt]
these aren't actually solutions per se, but double checking of a couple possible oversights. if these don't produce a proper answer, it would be worth it for you to post again.
as to your task, it is possible (of course, assuming perl is running as a user who has the ability to change the permissions of the directory in question). if you find that stat isn't working for you, you can always open up pipes to commandline calls, parse the returned text, and work with that instead. this should only be looked at as a final resort, as it takes more work than using the perl functions, but it will work if nothing else will.
HTH "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."