I have two files one unzipping.pl and another Main_Start_File.pl.
I am calling unzipping.pl from Main file ...
problem is that when i uncomment the commented part of Main file it is not executing unzipping.pl whereas when i run it with commented part it is going to unzipping and unzipping all file
below is my code
main_file.pl
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP::Recursive ;
require "unzipping.pl";
my $host = "xx.xx.xx.xx";
my $user = "tt";
my $password = "tt";
my $basedir = "locations";
my$reportfldr = "reports";
my $filename = 'List.txt';
my $date = "20161128";
#my $brchid="b00330";
############Fetching report from Server####################
open(my $fh, '<:encoding(UTF-8)', $filename)or die "Could not open fi
+le '$filename' $!";
while ( my $brchid = <$fh>) {
chomp $brchid;
print "$brchid\n";
# system "mkdir $brchid";
# chdir($brchid);
# system "mkdir $date";
# chdir ($date);
# my $dir = join"/",$basedir,$brchid,$reportfldr,$date;
# my $f = Net::FTP::Recursive->new($host,Debug => 0) or die "Can't
+ open $host\n";
# $f->login($user, $password) or die "Can't log $user in\n";
# $f->binary();
# $f->cwd($dir) or die "Can't cwd to $dir\n";
# $f->dir();
# $f->rget();
# $f->quit;
# print " I am entering into subroutine \n";
&unzipping($brchid,$date);
# sleep 5;
# chdir "../..";
}
unzipping.pl
#!/usr/bin/perl
use strict ;
use warnings ;
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
sub unzipping{
my $brchdir = $_[0];
my $date = $_[1];
my $dir1 = "Transaction_Reports";
my $dir2 = "Reports_On_Request";
my $dir3 = "Other_Reports";
my $dir4 = "MIS_Reports";
my $dir5 = "Letters_Reminders";
my $dir6 = "Exception_Reports";
my $dir7 = "Concurrent_Audit_Reports";
my $dir8 = "Adhoc_Audit_Reports";
my $dir = $brchdir."/".$date;
print "I m in unzipp dir $dir \n";
my $dirf=$dir."/".$dir1;
my $dirs = $dir."/".$dir2;
my $dirt = $dir."/".$dir3;
my $dirft = $dir."/".$dir4;
my $dirfv = $dir."/".$dir5;
my $dirsx = $dir."/".$dir6;
my $dirsn = $dir."/".$dir7;
my $direi = $dir."/".$dir8;
print "I m here \n" ;
print " $dir";
for my $input ( glob "$dir/*.gz" )
{
print " I m inside for $dir \n";
my $output = $input;
$output =~ s/.gz// ;
gunzip $input => $output
or die "Error Uncompressing '$input': $GunzipError\n";
}
}
1;