Reputation: 639
I've created a variable $date in Main.pl script that I would like to pass to Annotator.pl script. I use shell script to execute Annotator.pl. I can't figure out how to pass $date to Annotator.pl. When I run my $date = $ARGV[0];
in Annotator.pl I get the name of the current directory, however, $date = $ARGV[1];
returns nothing.
Please see the code below. The date is important because it has to be exact and I can't figure out how to pass it to Annotator.pl. Thanks for your help.
Main.pl Script:
#!/usr/bin/perl -w
use strict;
use warnings;
my $sec; my $min; my $hour; my $mday; my $mon; my $year; my $wday; my $yday; my $isdst;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
$mon=$mon+1; $year = 1900+$year;
if (length($mon)==1) {$mon="0".$mon;}
if (length($mday)==1) {$mday="0".$mday;}
if (length($hour)==1) {$hour="0".$hour;}
if (length($min)==1) {$min="0".$min;}
if (length($sec)==1) {$sec="0".$sec;}
my $date = "$mon"."_"."$mday"."_"."$year"."-".$hour.$min.$sec;
my $cmd5 = `perl MDL_unzip_annotate.sh /data/test_all_runs pVCF $date`; print "$cmd5";
Shell script: MDL_unzip_annotate.sh that executes Annotator.pl
home="/data/test_all_runs" #location of the run directory from which the program is launched
scripts="/data/test_scripts"
datapath=$1 #this is called in Main.pl as [test_all_runs]
process=$2 #the process
if [[ "$process" == "pVCF" ]];then
cd $datapath
folders="$(ls)"
cd $scripts
for ff in $folders; do
dname=$ff
echo $dname
if [ ! -f $dname ];then
cmd2="perl Annotator.pl $dname"
echo $cmd2
cmd2=`perl Annotator.pl $dname`
echo $cmd2
fi
done
done
fi
Annotator.pl script:
#!perl
use strict;
use warnings;
my $date = $ARGV[1]; print "the date is######## ".$date."\n";
Upvotes: 0
Views: 86
Reputation: 639
Instead of using shell script I will use the following code to capture the name of the folder in a specific directory:
opendir my $dir, "/data/test_all_runs" or die "Cannot open directory: $!";
my @run_folder = readdir $dir;
closedir $dir;
my $last_one = pop @run_folder; print "The folder is".$last_one."\n";
Thanks for your suggestions.
Upvotes: 1