<p>I want to wrap a <a href="https://en.wikipedia.org/wiki/One-liner_program#Perl" rel="nofollow noreferrer">Perl one-liner</a> in a batch file. For a (trivial) example, in a Unix shell, I could quote up a command like this:</p>

<pre><code>perl -e 'print localtime() . "\n"'
</code></pre>

<p>But DOS chokes on that with this helpful error message:</p>

<blockquote>
  <p>Can't find string terminator "'" anywhere before EOF at -e line 1.</p>
</blockquote>

<p>What's the best way to do this within a <a href="https://en.wikipedia.org/wiki/Batch_file" rel="nofollow noreferrer">.bat file</a>?</p>

For Perl stuff on Windows, I try to use the generalized quoting as much as possible so I don't get leaning toothpick syndrome. I save the quotes for the stuff that DOS needs:
```
```
perl -e "print scalar localtime() . qq(\n)"
```
```
If you just need a newline at the end of the print, you can let the
```
-l
```
switch do that for you:
```
```
perl -le "print scalar localtime()"
```
```
For other cool things you can do with switches, see the
perlrun
documentation.