Ramnarayan
Programmer
Hi,
I just made a simple subroutine to check whether the zip file has jpg files. However the script is working great. But whenever it tests a zip file that does not have a jpg file, it should do the other part of the loop. This is not working... Can someone help me!
my $has_jpg = "FALSE";
open (JPG, "unzip -t fff.zip | grep jpg |"
or die "Can't get JPG files from zipfile\n";
while(<JPG>)
{
if (m/OK\s*$/)
{
$has_jpg = "TRUE";
last;
}
}
close (JPG);
if ($has_jpg = "TRUE"
{
&withjpg;
}
elsif ($has_jpg = "FALSE"
{
&nojpg;
}
sub withjpg
{
!system("unzip -qq $fff.zip *.txt *.jpg *.rpt"
or die ("can't unzip zip file: $!"
;
}
sub no jpg;
{
!system("unzip -qq fff.zip *.txt *.rpt"
or die("can't unzip zip file: $!"
;
}
I just made a simple subroutine to check whether the zip file has jpg files. However the script is working great. But whenever it tests a zip file that does not have a jpg file, it should do the other part of the loop. This is not working... Can someone help me!
my $has_jpg = "FALSE";
open (JPG, "unzip -t fff.zip | grep jpg |"
while(<JPG>)
{
if (m/OK\s*$/)
{
$has_jpg = "TRUE";
last;
}
}
close (JPG);
if ($has_jpg = "TRUE"
{
&withjpg;
}
elsif ($has_jpg = "FALSE"
{
&nojpg;
}
sub withjpg
{
!system("unzip -qq $fff.zip *.txt *.jpg *.rpt"
}
sub no jpg;
{
!system("unzip -qq fff.zip *.txt *.rpt"
}