in reply to Windows - have program replace itself
Okay folks, here is the results of playing with this idea:
- Don't trust Windows, well to be specific, don't trust Perl in Windows to return what you think it should return. In my case I am developing in Komodo, so when I have Komodo run the programme, the value of $0 is something else altogether!
- If I use PerlApp from Komodo (which I do anyway) then $0 returns a sensibble value. BUT JediWizard the exec($0); doesn't work as you would expect. But purely using exec("appname.exe"); works just fine.
- Now, sgifford: I have packaged the app using PerlApp. This is some testing code:
As you can see with the programme running I renamed the .exe file, and then copied a new file from the ftp server with the same name. So that all worked nicely.unlink 'appname_old.exe'; rename ( 'appname.exe', 'appname_old.exe'); use Win32; my $localdir = Win32::GetCwd(); print "My idea of a local directory: " . $localdir . "\n"; print "I think I am program: $0 \n"; use Net::FTP; my $ftp = Net::FTP->new( "myftpserver.net", Timeout => 30, Debug => 0 ) or warn "Can't connect: $@\n"; $ftp->login( 'anonymous', 'guest') or die "Couldn't authenticate"; $ftp->cwd("/pub"); $ftp->type( "I" ); $ftp->get('appname.exe'); $ftp->quit; debug( "Quitting, restart programme please." ); exec("appname.exe"); - Now waswas-fng suggests using PAR and running with parts of the programme remote. That's a neat idea. My application packages nicely with PAR and the idea of caching in-between is rather nice. I will lookinto it, thank you!
- Now finally, Zero_Flop, thanks for the suggestion. Sadly, these folk are typical Windows users - ask them to open a command prompt and they go all glassy-eyed on you!
In Section
Seekers of Perl Wisdom