Home: Perl Programming Help: Intermediate:
Restart/reload an impress from Perl

New User

Apr 8, 2014, 2:38 AM

Views: 7137
Restart/reload an impress from Perl

Hi all,

I’m currently working on a project in which I would like to be able to restart an impress presentation from a perl script.
The script works just fine, it kills the presentation and restarts it, but the problem is that the script freezes after restarting the presentation. It never prints “Script end!”.
I know this is both a impress and mostly a perl related question but I was still wondering if someone could help me out?
Maybe there is a much simpler way (command) to restart an impress presentation?

My script looks like this:

if ($filesize != $filesize2)
{system(“cp -f /home/picuntu/Temporary/Presentatie.odp /home/picuntu/Desktop/Presentation.odp”);
system(“pkill -9 -f Presentation.odp”);
system(“libreoffice —quickstart -show —norestore /home/picuntu/Desktop/Presentation.odp”);
print “/n” . “Script end!” . “/n”;

Any help would be much appreciated,

Kind regards,


Veteran / Moderator

Apr 8, 2014, 6:23 AM

Views: 7128
Re: [dwaynepeeters] Restart/reload an impress from Perl

Why are you using 'cp' and 'pkill' system calls? Are you not aware that perl has the built-in kill function to kill a process and the File::Copy module to copy files?

The script is not "freezing". The system function forks a new (child) process to run the command and waits for that process to complete/exit before proceeding to the next statement.

If you want it to return immediately, you'll need to run libreoffice as a background process.

system("libreoffice —quickstart -show —norestore /home/picuntu/Desktop/Presentation.odp &");

A better method to do that would be to use the Proc::Background module.

use Proc::Background; 

my $cmd = "libreoffice —quickstart -show —norestore /home/picuntu/Desktop/Presentation.odp";
my $libreoffice = Proc::Background->new($cmd);


(This post was edited by FishMonger on Apr 8, 2014, 6:24 AM)