2

I use W7 64bit and I just installed strawberry perl. I need to execute a simple script from windows command line for manipulation of text files:

perl -ne 'chomp; print "$_ O O O O\n"' test.txt > textformatted.txt

I get error:

Can't find string terminator "'" anywhere before EOF at -e line 1.

It's in the PATH and also I can call perl -v. I tried adding spaces, replacing ' with ", backslashs etc. but no use.

I looked at tutorials and searched on the web and I found a lot of statements like this so it seems that this statement should work. But it doesn't.

Can somebody please help me? Where is the mistake?

toro2k
  • 19,020
  • 7
  • 64
  • 71

1 Answers1

3

You need to change your single quotes to double quotes.

perl -ne "chomp; print qq($_ O O O O\n)" test.txt > textformatted.txt
Ron Bergin
  • 1,070
  • 1
  • 6
  • 7
  • Thank you! So I can always put qq() on stuff that should be under quotes? – user2277690 Apr 13 '13 at 15:46
  • Yes. Since the shell (i.e., cmd.exe) uses the double quotes for its quoting, you'll need to use either qq(..) or a heredoc when you need double quoted string var interpolation in oneliners. – Ron Bergin Apr 13 '13 at 16:10