0

I'm executing a perl regex command using batch like:

perl -p -e "<my regex>" c:\file.txt
PAUSE

How can I tell perl to return it as a veriable and then print the result using batch echo?

3
  • The perl script will print to STDOUT already, you do not need to print it with echo. Commented Feb 20, 2013 at 13:37
  • Of course I do not only want to print it out, I also want to use the found value in further batching. So I need to get it from perl. Commented Feb 20, 2013 at 13:38
  • @membersound, it helps if you say what you are really doing in the first place. Commented Feb 20, 2013 at 13:55

1 Answer 1

2
@echo off
for /f "delims=" %%q in ('perl -e"print q{a b c}"') do set var=%%q
echo %var%
pause

or

@echo off
for /f "usebackq delims=" %%q in (`perl -e"print 'a b c'"`) do set var=%%q
echo %var%
pause
Sign up to request clarification or add additional context in comments.

1 Comment

OK this would print "a b c", but still how get I return values from a regex match that looked the expression up in the file?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.