i am assuming you want to do this on your own PC. else don't use this code unless you are sure you know what you're doing. using the shell in for example a server environment can be dangerous. One sure don't want to use any user inputs with something like this.
With that said.
Download 7za.exe command line 7zip utility on this page: http://www.7-zip.org/download.html it is labeled "32-bit 7-Zip Command Line Version". Extract 7za.exe into some folder. I put things like that into a directory named C:\Program_Dropins
Below is something i slung together. In the past I have had to deal with archive files before. I think the code and comments pretty much speak for themselves. It should work if you have spaces in paths but normally I try to avoid spaces in windows scripts if i can.
Read the help file that comes with 7za.exe for plenty of options. If you are really new to 7zip command line I found this good page http://www.dotnetperls.com/7-zip-examples
Good luck!
#!/usr/bin/perl -w
use strict;
my %configs = (
'7zexe' => "C:\\Program_Dropins\\7zip\\7za.exe",
'dir1' => "C:\\Folder1",
'dir2' => "C:\\Folder2"
);
my $zip_file = '7zip.7z';
# note the -o must touch the output dir. its a 7zip thing not perl
# -y assumes yes to all promps
my $output = `\"$configs{'7zexe'}\" -y e \"$configs{'dir1'}\\$zip_file\" -o\"$configs{'dir2'}\"`;
if ($output =~ /Everything is Ok/g){
print "Worked\n";
}
else{
print "Sorry\n";
}
sleep 5;