I'm really new to Batch and Perl, so please excuse me if I'm tackling my problem the wrong way. My task right now step by step:
- Execute Perl script which will generate a Batch file.
- When the Batch file is executed, a Collaborator review will be created using
adddiffs new (...)and then files will be added usingaddfiles (...)
Currently the problem is that sometimes the review creation process will fail for whatever reason (I'm not really told why, just that it does) but despite the adddiffs command failing, addfiles last (which is how it's currently coded) will still execute, which ends up adding the files to the wrong review. For example I'm trying to create review 10, but the review creation fails and the files end up getting added to review 9 which is obviously not what we want.
I'm trying to dump the output from adddiffs new into a text file, which I then extract the review # from using some perl script. What I then want to do is use the extracted review # to execute addfiles reviewNum instead of addfiles last since it seems like addfiles last might be causing unexpected behavior.
What my Batch file looks like:
@rem= 'PERL for Windows NT
@echo off
ccollab.exe adddiffs new Original_Files Changed_Files > output.txt
C:\Perl\bin\perl GenerateReview.bat%*
goto endofperl
@rem ';
open(TXT, "output.txt") or die;
$lastLine = "";
while ($line = <TXT>) {
$lastLine = $line;
}
($revNum) = $lastLine =~ /(\d+)/ig;
close TXT;
__END__
:endofperl
ccollab.exe addfiles $revNum *.txt *.pdf *.html *.doc* *.xls* Info_Only/*
pause
Is there a way I can get the $revNum from the perl script and substitute it for my addfiles command?
Can be done like this (not tested):
Perl's output is captured into REVNUM variable, which later used when running
ccollab.exe.And if we pass
output.txtas an argument to perl, the script can be simplified to:And it can be even more compact if we put the perl code inline: