1

I know that one should not mix languages but I don't find another way.

I have a Batch Script that starts a Perl Script. This Perl Script writes a value in a variable. I want that that the Perl Variable is returned to a Variable within the Batch Script.

Batch-Script:

:: Log-File
set logfile=.\yesterday_%TIMESTAMP%.log

:: start main program
call :main >>%logfile% 2>&1
exit /b

:: main program
:main

call "C:\myperl\perl\bin\perl.exe" ".\yester.pl"

Perl-Script:

use DateTime qw( );
use Date::Parse;
use Date::Language;

my $lang = Date::Language->new('German');

my $yday_date =
   DateTime
      ->now( time_zone => 'local' )
      ->set_time_zone('floating')
      ->truncate( to => 'day' )
      ->subtract( days => 1 )
      ->epoch;

print $lang->time2str('%b%d', $yday_date) . "\n";

Is this even possible and if yes, how?

Any answer is appreciated.

Stelios
  • 414
  • 9
  • 21

1 Answers1

2

I found a way. This line in the batch script works for me:

for /f "tokens=*" %%a in ('perl yester.pl') do set yester=%%a
Stelios
  • 414
  • 9
  • 21