carterniall has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks

I have a perl script which uses LWP:UserAgent to mirror the contents of a URL to a file

my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; $ua->mirror($url.$url_suffix,"../../../public_html/preview.kml");
What I would like to do is ensure that the file (whenever updated) maintains 755 permissions.

This is so that the file can be used in a Google Map

Any support would be champs!
Niall

Replies are listed 'Best First'.
Re: Changing file permissions in perl
by moritz (Cardinal) on Jul 17, 2008 at 12:49 UTC
Re: Changing file permissions in perl
by pc88mxer (Vicar) on Jul 17, 2008 at 12:49 UTC
    Try setting your "umask" with umask(0022). Alternatively, simply chmod the file after the mirror method returns:
    $ua->mirror(..., $path); chmod 0755, $path;
Re: Changing file permissions in perl
by leocharre (Priest) on Jul 17, 2008 at 14:29 UTC
    You may want to look at rsync, it can be used to update across a network. It can maintain permissions, etc . Here's an example.