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.

2
  • 1
    Does stackoverflow.com/questions/6359820/… answer your question ? Commented Dec 9, 2020 at 14:29
  • I found another way see my answer below. Thanks anyway Commented Dec 9, 2020 at 14:53

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.