简体   繁体   中英

How can I call winrar in perl on windows

Is it possible to call winrar through perl on a windows system, such as

perl -e "rar a -rr10 -sc:\\backups\\backup.rar @backup.lst"

If so, is there a more efficient way to do this?

I've looked up "perl -e" +winrar on google, however none of the results gave me any answer that was remotely close to what i was looking for. The system Im running this on is a Windows XP system. Im open to doing this in another language like python if its easier, however I am more comfertable with perl.

You can access the RAR facilities in Windows using the CPAN module Archive::Rar :

use Archive::Rar;
my $rar = Archive::Rar->new(-archive => $archive_filename);
$rar->Extract();

One way to execute external commands from a Perl script is to use system :

my $cmd = 'rar a -rr10 -s c:\backups\backup.rar @backup.lst';
if (system $cmd) {
    print "Error: $? for command $cmd"
}

To use external applications from your Perl program, use the system builtin.

If you need the output from the command, you can use the backtick (``) or qx operator as discussed in perlop . You can also use pipes as discussed in perlipc .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM